The snippet
Copy the snippet from your widget page in the dashboard. It looks like this:Embed code
- The iframe loads the widget for your widget ID.
titleandkeywordstell it what the article is about. - The script listens for messages from the widget. It resizes the frame as the trade panel opens and closes, and hides the frame entirely when no relevant market matches. See postMessage events.
Fill in the title and keywords
Replace the two placeholders with your CMS variables:
In the copied snippet the braces are already URL-encoded, so the placeholders appear as
%7BARTICLE_TITLE%7D and %7BARTICLE_KEYWORDS%7D. Replace the whole placeholder, braces included.
Both values must be URL-encoded. Most template languages have a filter for it, for example {{ title | urlencode }}. See CMS templates for examples.
The rendered src for one article looks like:
Placement
- Put the widget where a related sidebar or “in this story” box would go: after the first few paragraphs, or at the end of the article.
- The frame is
width="100%"and capped atmax-width:560px. You can change the inline style to fit your column, for examplemax-width:100%to fill a wider slot. - Keep
loading="lazy"so the widget loads only when readers scroll near it. - Use one snippet per page. If you place more than one, give each iframe a unique
idand point each script at its own frame.
Attributes you must keep
Content Security Policy
If your site sends aContent-Security-Policy header, allow the widget host as a frame source:
script-src without 'unsafe-inline', move the listener script into one of your own script files or add it to your policy with a nonce or hash. The widget itself needs nothing else from your page.
Single-page apps
In React, Vue and other client-rendered apps, render the iframe as a component and attach the message listener in an effect. See the React example.Next steps
Test your embed
Check matches and collapse behavior before you publish.
Embed URL reference
Every query parameter the widget accepts.