Adding custom code to CMS with Integromat

I’d like to have a dynamic custom code to manage advertisements, and I can’t figure out, how to add a custom code with Integromat. I know adding custom code in CMS is possible (Custom code in the CMS | Webflow University), however, when I add an HTML as plain text, I get this HTML as plain text on the corresponding page. If I convert this text with Markdown → HTML, Webflow cuts all HTML Any ideas on how I can achieve that? Thank you in advance.

Custom code example:

<div id="amzn-assoc-ad-948ce5d2-e4d5-4cbd-8c6f-835794af335a"></div>
<script async src="//[z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=948ce5d2-e4d5-4cbd-8c6f-835794af335a](http://z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=948ce5d2-e4d5-4cbd-8c6f-835794af335a)"></script>

You probably need to decode the encoded code (with custom code or a JS plugin) so it will run in the page. Webflow encodes code by default and since you can’t create embeds outside the designer this is the option. You did not share an example page so I could not check for you.

Thank you for your quick reply! So, I have to use an embed, linked with the CMS object? Not a rich text?

Custom code will only render as code when it is placed in an code embed, inside a RTF, through the designer or in and embed element placed on a page, or in the header or footer code areas.

If you use Integromat (anything) to inject custom code into a RTF it gets encoded by Webflow which means you can see it but it won’t render. You could write a custom script to decode the HTML entities or use a plugin like he.js (GitHub - mathiasbynens/he: A robust HTML entity encoder/decoder written in JavaScript.).

Thanks! I tried to create a simple project with an embed, but I can’t make it work. Could you take a look please?

I suggest you read an article I wrote that explains the problem as well as provides a solution. See => Render Custom Code from Webflow CMS Item’s Value (wfhow.com)

I did everything as described, but it looks like I missed something. I see the script decodes the field and substitutes the embed object, but it’s not visible — https://custom-code-in-cms.webflow.io/items/the-history-of-web-design

I suggest you get your script working in a codepen to isolate your issue. wf forum 117254 (codepen.io)

Thank you for your help. What’s strange is that if I copy the code from the browser’s rendered page and past it in Codepen, everything works. However, the browser doesn’t show it. Can it be a security issue that prevents embeds?

Have you tried to place the field value (not the script tags) into an embed as the src attribute?

I’m not sure I understood. Have I tried to manually place this code to an embed? Yes. I tried, it works. And it works if I put it as a custom code in a rich text block. Or it’s not your question?

It looks like the moment the page renders, the div with the ad is not ready yet. I added an Instagram embed, and it isn’t loaded at the moment of render too. Shouldn’t the function that changes the embed inner HTML be async?

I added different types of embeds — Amazon Ad, Twitter, Instagram, Youtube Video, Amazon products. Only <iframe> type of embed works.

Alexey I am tied up with work right now and can’t guarantee when I can circle back to help you.

No worries. When you have time.
Thank you!

@Chekanov did you ever manage to get this working? I have exactly the same problem I think, any clues would be much appreciated!

Unfortunately, no. It still doesn’t work.