# I finally figured out how to get the dynamic content working on external Wordpress site (hint: CORS-settings)

**URL:** <https://forum.mautic.org/t/i-finally-figured-out-how-to-get-the-dynamic-content-working-on-external-wordpress-site-hint-cors-settings/24281>\
**Category:** Development\
**Created:** [May 31, 2022, 5:19am UTC](https://forum.mautic.org/t/i-finally-figured-out-how-to-get-the-dynamic-content-working-on-external-wordpress-site-hint-cors-settings/24281 "2022-05-31T05:19:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![calle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/calle/32/6739_2.png) [@calle](https://forum.mautic.org/u/calle)\
**Post date:** [May 31, 2022, 5:19am UTC](https://forum.mautic.org/t/i-finally-figured-out-how-to-get-the-dynamic-content-working-on-external-wordpress-site-hint-cors-settings/24281/1 "2022-05-31T05:19:06Z")

</div>

Hello,  
After banging my head against the wall trying to figure out how to embed dynamic content on an external Wordpress site, the wall finally broke before my head did.

I have been trying to find information about this but documentation has been rather sparse, or outdated so i tought i’d make a little writeup of my findings in hopes it might be useful to someone;

Im running Mautic 4.0.1  
The Wordpress site is sitting on a different domain  
I am running the WP Mautic plugin in Woocommerce, i guess it is a requirement but i have not tried without it so i can’t be sure.

I created dynamic content using both the methods mentioned here, [Dynamic Web Content — Mautic Documentation 0.1 documentation](https://docs.mautic.org/en/components/dynamic-web-content) , both filter-based and campaign-based, but i could not get them to show up on the Wordpress site.

Forms generated by Mautic did show up, though, which i found strange.

**Always test in another browser, i do the admining in Chrome but i use Edge as a “user-test-platform”, reason being you cant be logged in to Mautic at the same time, it won’t work**

After sifting through the whole of Google, i saw mentioning of CORS (Cross-Origin Resource Sharing).  
I inspected the page and behold, CORS-errors that clearly stated that no access-control-allow-origin was present, my wordpress site was not whitelisted to request resources if i understand correctly what was going on.

 ![cors1](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/2/2d164dd27227097f346968b29e7ac54b37006c18.png)

So i entered this into the .htacess file on my Mautic installation;

# Enable CORS

Header set Access-Control-Allow-Origin “[https://pureest.se](https://pureest.se)”

Which did not work, because i left out a www;

 ![cors2](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/f/ffd993fec90a88279381fae0d30cff75453173d6.png)

Added www, and then got new exciting errors;

 ![cors3](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/0/08ffe5c2ec9ef9d89724f780feb72fc1443eb0eb.png)

Added this line to the htacess;  
Header set Access-Control-Allow-Credentials true  
and got new errors;

 ![cors4](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/4/48e2d58533b3b9d134640d73b3ba8757df6b228b.png)

Finally added this line to htaccess;  
Header set Access-Control-Allow-Headers: “X-Requested-With”

And was greeted by this;

 ![cors5](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/f/f830d1c7968931517e3154204ffb2c11e21f0cbf.png)

Htacess additions i did not need to use, but found during my travels, i don’t know what these do but someone else might?  
Header set Access-Control-Allow-Methods": “GET,HEAD,OPTIONS,POST,PUT”,  
Header set Access-Control-Allow-Headers: “Origin, X-Requested-With, Content-Type, Accept, Authorization”

Final shot of htaccess, green bits are commented out and not used;

 ![htaccess](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/8/835447f60ff93f7570630c675d1143c7320aa068.png)

I had never heard of a CORS and did not know whether it was a cheese or something you smoked before i ran into this, but I’m so glad i got it working! Hope this helps someone!

Cheers Carl

---

<div class="post-metadata">

**Author:** ![tobsowo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/tobsowo/32/3096_2.png) [@tobsowo](https://forum.mautic.org/u/tobsowo)\
**Post date:** [May 31, 2022, 7:42am UTC](https://forum.mautic.org/t/i-finally-figured-out-how-to-get-the-dynamic-content-working-on-external-wordpress-site-hint-cors-settings/24281/2 "2022-05-31T07:42:38Z")

</div>

This is helpful for the community. Thank you.

---

<div class="post-metadata">

**Author:** ![victoriagr](https://avatars.discourse-cdn.com/v4/letter/v/4491bb/32.png) [@victoriagr](https://forum.mautic.org/u/victoriagr)\
**Post date:** [April 5, 2023, 9:36am UTC](https://forum.mautic.org/t/i-finally-figured-out-how-to-get-the-dynamic-content-working-on-external-wordpress-site-hint-cors-settings/24281/3 "2023-04-05T09:36:27Z")

</div>

Hi Carl, I have the following problem. I’ve created dynamic content on the homepage of my WordPress site, but when I search for it on Google (in private mode), the dynamic content doesn’t load by default. I have to hit F5 to refresh the page and then the content appears. Do you think this could be the source of the problem?
