MailChimp Popup Form Breaking The Website

I’m using MailChimp for my mailing list and I wanted to add a subscription exit-intent popup to my website but for some reason when I add the code, everything that uses javascript on the website breaks.

Here is the code snippet:

<script type="text/javascript" src="//s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us16.list-manage.com","uuid":"44980dd1606c3371b3e8db0b5","lid":"46e7e5ad74"}) })</script>

Thanks in advance,
Martin

Hi Martin,

It should be added using a child theme. Add something like this on your child theme functions.php file.

function my_custom_head_output() {
  ?>
   <script type="text/javascript" src="//s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us16.list-manage.com","uuid":"44980dd1606c3371b3e8db0b5","lid":"46e7e5ad74"}) })</script>
  <?php
}

add_action( 'wp_head', 'my_custom_head_output', 99999 );

For more customization guide, see this: https://theme.co/apex/forum/t/customizations-best-practices/205

Tried using a function but it did the same mess… everything that uses JavaScript breaks - such as X-Theme flipping cards and sliders. The interesting part is that third party stuff on my site don’t have this issue - such as the Slider Revolution plugin and the Testimonial Rotator plugin, even though they use JavaScript

Hi there,

The code you are using the cause of the problem as much as my knowledge limit allows me to judge.

In some part of the code there is a Require JS call:

require(["mojo/signup-forms/Loader"]

That is not possible if you do not have the Require JS library installed.

I wonder why you do not use the Email Forms plugin which does have the forms capability for the MailChimp:

Then you can use the ConvertPlus plugin to add the popup and have the Emails Form shortcode inside it:

https://theme.co/apex/forum/t/extension-convertplug/66

Thank you.

I don’t think that Require.js causes the issue here. because the popup works fine only the X-Theme JavaScript using elements get messed up.

Regarding the Email Forms and ConvertPlus plugins, that’s what I’m using meanwhile but I really don’t want to have to use all these heavy plugins for something so small as this popup when I have the correct code snippet.

Why waste a whole lot of data which then affects page loading time and google ranking with heavy duty plugins I don’t need?

Hi there,

The reason I asked you to consider checking those plugins is that the particular code you are trying to use is not working and we could not find the reason why.

I tried to give alternative ways to achieve your goal.

Thank you for your understanding.