How to Embed a Widget on Magento / Adobe Commerce
Magento (now Adobe Commerce) is a powerful e-commerce platform used by enterprise and mid-market stores worldwide. By embedding Embeddy widgets, you can add interactive product configurators, size calculators, ROI tools, quizzes, and more to any page — without building a custom Magento extension. This guide covers three methods: CMS static blocks, CMS widgets, and layout XML.
On this page
Prerequisites
Before you start, have the following ready:
- Your Embeddy embed code. Log in at https://embeddy.ai/dashboard, open your widget, and copy the iframe embed code:
<iframe src="https://embeddy.ai/webhost/WIDGET_ID?widget_props_id=PROPS_ID" width="100%" height="500" frameborder="0" ></iframe>
- Magento admin access. You need administrator privileges to create widgets, static blocks, and manage content.
- Magento 2.x or Adobe Commerce. This guide targets Magento 2. For Magento 1 (legacy), the admin paths differ but the CMS block concept is similar.
Important: Magento's WYSIWYG editor may filter out iframe tags by default. You will need to use the HTML source editor or configure TinyMCE to allow iframes. See the troubleshooting section below for details.
Method 1: CMS Static Block
Easiest — use the admin panel
CMS static blocks are reusable HTML content snippets that can be placed on any CMS page or referenced from layout XML. This is the quickest way to embed a widget without touching code files.
- 1
Create a new static block
In the Magento admin, go to Content > Blocks and click "Add New Block". Give it a title like "Embeddy Widget" and an identifier like
embeddy_widget. - 2
Switch to HTML source and paste embed code
In the content editor, click "Show / Hide Editor" or the HTML source button to switch to raw HTML mode. Paste your Embeddy iframe embed code:
<div class="embeddy-widget-wrapper" style="max-width: 800px; margin: 2rem auto;">
<iframe
src="https://embeddy.ai/webhost/WIDGET_ID?widget_props_id=PROPS_ID"
width="100%"
height="500"
frameborder="0"
style="border: none; border-radius: 8px;"
loading="lazy"
title="Interactive Widget"
></iframe>
</div>- 3
Save and reference the block
Click Save Block. To display it on a CMS page, edit that page under Content > Pages and insert the block using the directive:
{{block id="embeddy_widget"}} - 4
Flush cache and verify
Go to System > Cache Management, flush the cache, and visit your storefront to verify the widget appears.
Tip: Static blocks can be reused across multiple pages and referenced from layout XML, making them extremely versatile for placing widgets throughout your store.
Method 2: CMS Widget Instance
Intermediate — visual placement control
Magento's widget system lets you insert content blocks into specific layout positions across your store — without editing template files. You can target specific pages, categories, or product types.
- 1
Create a new widget
Go to Content > Widgets and click "Add Widget". Select "CMS Static Block" as the widget type and choose your design theme.
- 2
Configure layout updates
Under Layout Updates, click "Add Layout Update". Choose where the widget should appear: "All Pages", "Specified Page", "Anchor Categories", etc. Select a Container like
Main Content AreaorAfter Main Content. - 3
Select the static block
Under Widget Options, select the static block you created in Method 1 (e.g., "Embeddy Widget").
- 4
Save, flush cache, and verify
Click Save, flush the Magento cache, and visit the targeted page to confirm the widget appears.
Tip: Widgets allow precise control over where content appears. You can target specific product categories, CMS pages, or even individual products — all from the admin panel.
Method 3: Layout XML and Template Override
Advanced — full developer control
For maximum control, you can add the widget via Magento's layout XML system and a custom PHTML template. This approach is ideal for developers who want the embed integrated into the theme at a specific position.
- 1
Create a custom PHTML template
In your theme directory, create a file at
app/design/frontend/YourVendor/yourtheme/Magento_Cms/templates/embeddy-widget.phtml:
<?php /** Embeddy Widget Template */ ?>
<div class="embeddy-widget-wrapper" style="max-width: 800px; margin: 2rem auto;">
<iframe
src="https://embeddy.ai/webhost/WIDGET_ID?widget_props_id=PROPS_ID"
width="100%"
height="500"
frameborder="0"
style="border: none; border-radius: 8px;"
loading="lazy"
title="Interactive Widget"
></iframe>
</div>- 2
Add layout XML to reference the template
Add a layout update in your theme's
default.xmlor a page-specific layout file (e.g.,catalog_product_view.xml):
<referenceContainer name="content">
<block class="Magento\Framework\View\Element\Template"
name="embeddy.widget"
template="Magento_Cms::embeddy-widget.phtml"
after="-" />
</referenceContainer>- 3
Deploy and flush cache
Run
bin/magento setup:upgradeandbin/magento cache:flushfrom the command line. In production mode, also runbin/magento setup:static-content:deploy.
Remember: Always make changes in a custom theme, not in the base Magento theme or vendor directory. Custom themes inherit from the parent and survive Magento upgrades.
Embedding on Product Pages
Product pages are one of the best places for interactive Embeddy widgets. Common use cases:
- Size calculators — help shoppers find the right size before purchasing
- Product configurators — let customers customize options interactively
- Compatibility checkers — verify parts or accessories work together
- ROI calculators — demonstrate savings for high-value items
Use Method 2 (CMS Widget) with the layout update set to "Catalog Product View" or Method 3 with the catalog_product_view.xml layout file to target product pages specifically.
For per-product widgets, you can create a custom product attribute to store the widget ID and reference it dynamically in your PHTML template.
Troubleshooting
The WYSIWYG editor strips my iframe tag
Magento's TinyMCE editor filters out iframes by default. Use the "Show / Hide Editor" toggle to edit raw HTML directly. Alternatively, configure TinyMCE to allow iframes by editing etc/adminhtml/di.xml in a custom module to extend the allowed HTML tags.
Widget shows a blank area or loading spinner
Verify your Widget ID and Props ID are correct. Copy the embed code fresh from the Embeddy dashboard and ensure the widget is published (not in draft mode).
Widget does not appear after saving
Magento aggressively caches content. Go to System > Cache Management and flush all caches. If using full-page cache (Varnish), purge it as well. In developer mode, caching may be disabled by default.
Content Security Policy (CSP) error
Magento 2.4+ enforces CSP headers. Add embeddy.ai to your csp_whitelist.xml file in a custom module under the frame-src directive. This allows Magento to load the iframe from embeddy.ai.
Widget is cut off on mobile
Ensure the iframe has width="100%". Add overflow: hidden to the wrapper div. Use Magento's responsive LESS/CSS framework to adjust the height at smaller breakpoints.
Frequently Asked Questions
Will embedding a widget affect my Magento store's performance?
Iframes load independently and do not block your main page render. Using loading="lazy" ensures the widget only loads when scrolled into view, preserving Core Web Vitals. Embeddy uses a global CDN for fast delivery.
Does this work with Magento Page Builder?
Yes. In Page Builder, add an HTML Code content type and paste your Embeddy iframe embed code. Page Builder will render the iframe on the storefront. Note that the preview in the admin may show a placeholder instead of the actual widget.
Can I use this with Adobe Commerce Cloud?
Yes. All three methods work on Adobe Commerce Cloud. For Method 3 (layout XML), deploy your theme changes via the standard Cloud deployment pipeline. Ensure embeddy.ai is whitelisted in the CSP configuration.
Ready to supercharge your Magento store?
Build a free interactive widget — size calculator, product configurator, quiz, or anything you need — and embed it on your store in minutes.
Create your free widget at embeddy.ai