Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MailChimp Popup Script that works with WordPress sites

MailChimp's default popup scripts can break on WordPress sites that use jQuery/jQuery UI unless you include their embed code as the final elements before the closing body tag.

Including them in this way isn't always possible or easy with WordPress.

The code below is an alternative implementation of the loader that forces MailChimp's popup scripts to appear below all other scripts upon page load.

To use it, modify the baseUrl, uuid, and lid attributes with the ones from the original popup script that MailChimp supplies.

<script>
    // Fill in your MailChimp popup settings below.
    // These can be found in the original popup script from MailChimp.
    var mailchimpConfig = {
        baseUrl: 'mc.us1.list-manage.com',
        uuid: 'a123456789abcdefghijklmno',
        lid: '1abc12345a'
    };
    
    // No edits below this line are required
    var chimpPopupLoader = document.createElement("script");
    chimpPopupLoader.src = '//s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js';
    chimpPopupLoader.setAttribute('data-dojo-config', 'usePlainJson: true, isDebug: false');

    var chimpPopup = document.createElement("script");
    chimpPopup.appendChild(document.createTextNode('require(["mojo/signup-forms/Loader"], function (L) { L.start({"baseUrl": "' +  mailchimpConfig.baseUrl + '", "uuid": "' + mailchimpConfig.uuid + '", "lid": "' + mailchimpConfig.lid + '"})});'));

    jQuery(function ($) {
        document.body.appendChild(chimpPopupLoader);

        $(window).load(function () {
            document.body.appendChild(chimpPopup);
        });

    });
</script>

Note that MailChimp stores a cookie for one year to prevent you from seeing a pop-up repeatedly after you've closed it or filled it in. If you're testing this you may need to clear cookies, use a different browser, or open a private browser window to see the form on repeat visits after dismissing or filling it.

Code provided under the ISC license.

@InteractM

This comment has been minimized.

Copy link

@InteractM InteractM commented Jan 25, 2016

Well done, mate!

@TP18

This comment has been minimized.

Copy link

@TP18 TP18 commented May 12, 2016

The only half of the Pop Up appears. I have no errors in the console log, but the rest doesnt appear. only the close button is there. any idea where the fields to subscribe & textarea's are?

@nickcernis

This comment has been minimized.

Copy link
Owner Author

@nickcernis nickcernis commented May 13, 2016

@TP18 Can you share a link to a page where I can see this? It sounds like it could be a CSS issue.

@manoose47

This comment has been minimized.

Copy link

@manoose47 manoose47 commented Jul 13, 2016

You wonderful human! I've been going mad over this all day; now it works like a charm! Many thanks!

@nickcernis

This comment has been minimized.

Copy link
Owner Author

@nickcernis nickcernis commented Jul 13, 2016

@manoose47 Glad it helped. :-)

@mannvyas25

This comment has been minimized.

Copy link

@mannvyas25 mannvyas25 commented Aug 2, 2016

Thanks a lot 👍 perfectly works for me.

@w3b-beweb

This comment has been minimized.

Copy link

@w3b-beweb w3b-beweb commented Aug 19, 2016

Thanks Dude! The only solution I've found that works perfectly.

@gino8080

This comment has been minimized.

Copy link

@gino8080 gino8080 commented Sep 27, 2016

Works perfect! 💯

@araceliat

This comment has been minimized.

Copy link

@araceliat araceliat commented Jan 1, 2017

For some reason it only works on the moble not the desktop version . . . .

@pbaheti

This comment has been minimized.

Copy link

@pbaheti pbaheti commented Jan 3, 2017

Works perfect!
Thanks

@BlackOut96

This comment has been minimized.

Copy link

@BlackOut96 BlackOut96 commented Feb 19, 2017

First popup code working. Thanks a lot!

@drupalninja1

This comment has been minimized.

Copy link

@drupalninja1 drupalninja1 commented Mar 2, 2017

You safe my life budy its perfect working without JS conflict with my other js code in website.
Works Perfect..!!!!

@chikaboo1

This comment has been minimized.

Copy link

@chikaboo1 chikaboo1 commented Apr 4, 2017

Saved me pulling my hair out. Thank you so much!

@bbodenmiller

This comment has been minimized.

Copy link

@bbodenmiller bbodenmiller commented Apr 6, 2017

On small screens sometimes other items will try to overwrite the banner, here's some code to help with that (put inside jQuery(function ($) {)

//don't allow menu to override on small screens
var tid = setTimeout(mycode, 1000);
function mycode() {
  if($('.mc-banner').length > 0){
    $('.mc-banner').css('z-index', 9999999999);
  } else {
    // keep trying until .mc-banner exists
    tid = setTimeout(mycode, 1000);
  }
}
@ICeZer0

This comment has been minimized.

Copy link

@ICeZer0 ICeZer0 commented Apr 24, 2017

Thanks dude!

@songfarm-david

This comment has been minimized.

Copy link

@songfarm-david songfarm-david commented May 3, 2017

What is the best way to include this code before the closing body tag?

Thanks

@songfarm-david

This comment has been minimized.

Copy link

@songfarm-david songfarm-david commented May 3, 2017

I got this to work and it worked beautifully - thank you.

Here's what I did: I took the code above and placed it into a new javascript file. In my (child theme's) functions.php file I created a new function. I attached the function to the wp_footer hook and used wp_enqueue_script within the function to load the script into my theme.

@tolba59

This comment has been minimized.

Copy link

@tolba59 tolba59 commented May 23, 2017

Finally it worked, many thanks to you, I was struggling the last 2 days trying to figure out this
And I still don't know how there is a known issue between MailChipm and Wordpress and there is no official fix for it !!
Thanks again for the help

@wiredcoyote

This comment has been minimized.

Copy link

@wiredcoyote wiredcoyote commented Jun 23, 2017

I have a client who wants to use a MC popup, and I couldn't figure out why it would work in Edge (of all things) but not in FF or Chrome.

The code works beautifully, cheers.

@wesblueyes

This comment has been minimized.

Copy link

@wesblueyes wesblueyes commented Jul 12, 2017

Thank you so much! To my confusing the popup was working on our dev site, but not the live site. This worked like a charm!

@hashguide

This comment has been minimized.

Copy link

@hashguide hashguide commented Sep 20, 2017

hey could you help me out? I am using one-page-express theme on wordpress and i tried entering the script above with my info in the head tag in header.php but it ended up breaking the site layout even after deleting it. Could you tell me what it could have change so i can reload the files needed to get it running right

@nickcernis

This comment has been minimized.

Copy link
Owner Author

@nickcernis nickcernis commented Sep 20, 2017

@hashguide It sounds like some code from the snippet is still in your header.php, or the page is being cached. You could try clearing caching plugins, restoring from a backup, or comparing the current header.php from a known-good version, like a backup copy or a fresh copy of the theme.

@Becca800

This comment has been minimized.

Copy link

@Becca800 Becca800 commented Sep 29, 2017

This worked great!! Thanks so much!

@tre1963

This comment has been minimized.

Copy link

@tre1963 tre1963 commented Oct 5, 2017

Thank you!! You are a legend

@khigashi

This comment has been minimized.

Copy link

@khigashi khigashi commented Oct 19, 2017

YOU ROCK!!!!

@cobman

This comment has been minimized.

Copy link

@cobman cobman commented Oct 25, 2017

Finally! Gonna write a song and sing your praises dude, thank you!

@luiszarza

This comment has been minimized.

Copy link

@luiszarza luiszarza commented Nov 2, 2017

You're amazing @nickcernis! Thank you so much.
I'd like to know you could tell me an easy way to trigger that popup from a button. So when you click that button the popup would display.
Thanks again

@zandergrin

This comment has been minimized.

Copy link

@zandergrin zandergrin commented Nov 2, 2017

great work - thanks

@nickcernis

This comment has been minimized.

Copy link
Owner Author

@nickcernis nickcernis commented Nov 4, 2017

@luiszarza To trigger an opt-in popup on click, I'd recommend a WordPress plugin such as https://optinmonster.com/ – it has a feature called MonsterLinks that lets you use a button or link as a popup trigger.

@carpecaseus

This comment has been minimized.

Copy link

@carpecaseus carpecaseus commented Nov 23, 2017

You are a hero @nickcernis - this has been driving me nuts for the last 2 days! Thank you very much!

@kingstakh

This comment has been minimized.

Copy link

@kingstakh kingstakh commented Nov 23, 2017

GREAT! Thank you!

@Wallace911

This comment has been minimized.

Copy link

@Wallace911 Wallace911 commented Nov 23, 2017

Hi dude, I want to display my MailChimp popup in only one page of my wordpress site's. Can you or anyome help me please?

@keeneyemedia

This comment has been minimized.

Copy link

@keeneyemedia keeneyemedia commented Dec 1, 2017

You rock! This is great!

@TonyKnucklez

This comment has been minimized.

Copy link

@TonyKnucklez TonyKnucklez commented Dec 3, 2017

Appreciate you Nick! Thanks champ!

@marcomarsala

This comment has been minimized.

Copy link

@marcomarsala marcomarsala commented Dec 12, 2017

URL of embed.js is now changed, replace the URL at line 12 with //downloads.mailchimp.com/js/signup-forms/popup/embed.js.
I forked and applied the fix.

@marcomarsala

This comment has been minimized.

Copy link

@marcomarsala marcomarsala commented Dec 12, 2017

The MailChimp slide popup form may cause horizontal scrollbar and double vertical scrollbars on some layouts

@ahmedbana

This comment has been minimized.

Copy link

@ahmedbana ahmedbana commented Jan 1, 2018

genius, i love you man, you saved my day

@Jmacrae3

This comment has been minimized.

Copy link

@Jmacrae3 Jmacrae3 commented Jan 2, 2018

Hey everyone, under what section of wordpress do i enter this code?

@inktank10

This comment has been minimized.

Copy link

@inktank10 inktank10 commented Jan 5, 2018

This seems to be what I have been looking for. Spent all day trying to figure out why my checkout page wan't working in internet explorer then found out the pop up form was breaking it. I think I followed the simple directions correctly. But my popup form is not popping up. word press is also giving me the error "strings must be sing quote" when pasiting this in the custom HTML widget. Any thoughts?

@Henry151

This comment has been minimized.

Copy link

@Henry151 Henry151 commented Jan 5, 2018

I have got the exact same problem as inktank10...I tried placing the code into the header.php file below the tag but it did not work either. Other than that, I also got the error "strings must be sing quote". Any thoughts are highly appreciated! ;)

@mattmagi

This comment has been minimized.

Copy link

@mattmagi mattmagi commented Jan 5, 2018

Thanks so much for this, it was driving me nuts, this worked great and I inserted it in the footer.

@Esaso

This comment has been minimized.

Copy link

@Esaso Esaso commented Jan 12, 2018

Very nice, thank you very much!

@TruCat

This comment has been minimized.

Copy link

@TruCat TruCat commented Jan 21, 2018

Thank you VERY MUCH!! I was struggling for hours and this works perfectly!!

@vinefruit

This comment has been minimized.

Copy link

@vinefruit vinefruit commented Feb 24, 2018

Wow this is brilliant thank you!

@andregufc

This comment has been minimized.

Copy link

@andregufc andregufc commented Mar 1, 2018

Thank you! It worked fine.

@MarcQueralt

This comment has been minimized.

Copy link

@MarcQueralt MarcQueralt commented Mar 2, 2018

Thank you, you did a great job.

@AlbaHerrerias

This comment has been minimized.

Copy link

@AlbaHerrerias AlbaHerrerias commented Mar 3, 2018

Thank you, It worked like a charm!

@jaycameronclark

This comment has been minimized.

Copy link

@jaycameronclark jaycameronclark commented Mar 9, 2018

Thanks for this!

@ALPJeff

This comment has been minimized.

Copy link

@ALPJeff ALPJeff commented Mar 10, 2018

My dude, you rock. Thanks for posting this!

@hub8

This comment has been minimized.

Copy link

@hub8 hub8 commented Mar 17, 2018

Still working! :)
My hero of the day. Thanks a lot, mate!

@hfortenberry

This comment has been minimized.

Copy link

@hfortenberry hfortenberry commented Mar 21, 2018

Hello,

I have gotten the mailchimp popup to work on another site but on this one (which has far fewer plugins to conflict - just jetpack, akismet, fastest cache, nextgengallery, Updraft and UserSubmitted Posts), I can only get the popup to work in the backend. It works when I'm logged into to the admin panel but I've tried everything to get it working on the front end to no avail. I've tried the following:

  • initially I pasted the mailchimp code into the footer of my child theme (before closing body tag), then
  • clearing history/cache on multiple browsers (Firefox, Chrome, IE, Safari, Opera)
  • using private/incognito browser windows
  • tried multiple computers (I work in IT and have access to many)
  • tried the code hack where you create another jquery.js file and upload it to the root on the server with a code snippet
  • your method here
  • a plugin (Mailchimp on WP)
  • Jetpack plugin where you add the mailchimp code to a widget

In every case, the popup works in the backend admin panel but not on the front end. Do you have any idea what could cause that? I have not seen anyone else mention it. I'm sure it's something obvious I'm just not seeing. I appreciate you!

Thank you,
Holly

@akwhitacre

This comment has been minimized.

Copy link

@akwhitacre akwhitacre commented Apr 3, 2018

Thank you! I tried several other methods recommended elsewhere and yours was the only one that worked!

@firxworx

This comment has been minimized.

Copy link

@firxworx firxworx commented Apr 9, 2018

Works well! Glad I Google'd first :)

In case it helps anyone, I had to adjust the js load order in my functions.php (e.g. add_action( 'wp_enqueue_scripts', 'enqueue_scripts_function_name' , 100); where 100 is the priority number) to load it below other js or else it was competing with some theme/plugin js and messing up on mobile.

I also noticed the latest Mailchimp snippet (generated earlier today) loads from //downloads.mailchimp.com/js/signup-forms/popup/embed.js not the aws URL in the gist so I switched to that as well and that works great too.

@GemBro

This comment has been minimized.

Copy link

@GemBro GemBro commented Apr 19, 2018

Duuuude! ... works great ... been getting a headache for hours ...

The only issue I have is ... I use the ENVISION WordPress Theme and the main header (with menu) is pi$$ing all over the top 1/4 of the popup ...

I know it's not your problem but would you know how I can bring the popup to the front of all other content on the screen? ... or maybe even move the popup down 1 inch or 2, with code, so it clears the header ...

Thank you.

@fcmiao

This comment has been minimized.

Copy link

@fcmiao fcmiao commented Apr 20, 2018

Thank you! It works perfectly!

@gavinwilshen

This comment has been minimized.

Copy link

@gavinwilshen gavinwilshen commented Apr 25, 2018

Excellent work! Thanks

@thiagovidal

This comment has been minimized.

Copy link

@thiagovidal thiagovidal commented Apr 28, 2018

Dude. You are the best! Thank you so much!

@MaloRchrd

This comment has been minimized.

Copy link

@MaloRchrd MaloRchrd commented May 17, 2018

Thanks it works great

@thesoulpathartist

This comment has been minimized.

Copy link

@thesoulpathartist thesoulpathartist commented May 17, 2018

HI all, I am trying to add a mailchipm popup script to my wordpress.org site, and I have been told I have to use enqueue, and place it in a child theme. I have been working with wordpress for a long time but mostly as a novice, no coding. Can someone advise how I do this? Thanks in advance for any help.

@SLynnBen

This comment has been minimized.

Copy link

@SLynnBen SLynnBen commented May 21, 2018

Kadence Themes (https://www.kadencethemes.com/add-a-mailchimp-popup-subscribe-form-to-your-site/) suggested I give your code a try. Followed instructions but doesn't seem to show up on exit. I have auto delete cache when I close browser. Don't know what I am doing wrong. Any help appreciated. Here's an image of the code I put in footer output. Just FYI... I also have the MailChimp connect to site code there as well.
www.celebratingyourjourney.com
mailchimpcodeissues-signuppopup

@mikeGski

This comment has been minimized.

Copy link

@mikeGski mikeGski commented May 23, 2018

I got this code to work with my wordpress site for the popup that comes up automatically. However, is there anyway to make this so the pop up comes up when a button on our site is clicked?

The problem is the embedded forms on Mailchimp aren't GDPR compliant... and the form builder which is compliant can't be popped up when you click a button as it takes you outside our site to mailchimp sign up which is not what we want. I like the look of the subscriber pop-up, which is GDPR compliant and until I used the code given on this page, the pop up wasn't working at all. Thanks for the code... and the automatic pop up does work now... however, we have "signup for newsletter" buttons on our site and looking for the forms to pop up on our site when the buttons are clicked... and have the form be GDPR compliant. So, is there any way to have this code above to pop up like it's supposed to (automatic popup) BUT we ALSO can use it when someone clicks a button and the pop up will show as well?

One other thing... I noticed after it pops up one time... it doesn't come up again if you refresh the page or revisit the site. How long does the cookies last on this before it pops up again?

@okosed1

This comment has been minimized.

Copy link

@okosed1 okosed1 commented May 25, 2018

This worked perfectly! Thank you :)

@mrjeanius

This comment has been minimized.

Copy link

@mrjeanius mrjeanius commented May 27, 2018

nickcernis thank you !! i lost a couple of hours trying on my own ... not good !!
great thinking and perfect execution , you saved my day !

@joshkremer

This comment has been minimized.

Copy link

@joshkremer joshkremer commented May 28, 2018

Works like a charm. Thank you! I just spent hours trying to sort this out before finding this.

@mstibbe

This comment has been minimized.

Copy link

@mstibbe mstibbe commented May 29, 2018

You're a deeply wonderful human being. Thanks for sharing this fix. I managed to break my ecommerce site with this Woo/Mailchimp conflict and I spent hours trying to unbreak it before I found this. Works fine now.

@AlexdeBorba

This comment has been minimized.

Copy link

@AlexdeBorba AlexdeBorba commented May 30, 2018

It did work for me, after struggling with the theme, it now loads without blocking jQuery. Thank you for your contribution.

@wtyzara

This comment has been minimized.

Copy link

@wtyzara wtyzara commented May 31, 2018

This worked for me, (thanks!!!) and I left my code in the footer.php before the /body.

However, can I check if there is any way for me to remove the cookies? the pop-up form only appears once after I close it, whether if it is a normal window or an incognito video... I would like my pop-up to ideally appear still when the unsubscribed user opens the website in a new window....

@BrunoBoehm

This comment has been minimized.

Copy link

@BrunoBoehm BrunoBoehm commented Jun 13, 2018

Hi all,
As a reference, building on your script @nickcernis here is a version that enables to open the MailChimp popup only when a Call to Action (button) is clicked, as well as integrates a few cookie settings to enable the button to be clicked and still re-open the modal (otherwise the modal can only be seen once on the first click). I've also had a few issues with the mailchimp popup javscript conflicting with other plugins, and it seems to be working well now thanks to your $(window).on("load", ... method (waits for all files - including javascript - to be loaded). As a sidenote the load event is deprecated/removed from jQuery 3.0. Instead you can use .on() method and bind the JavaScript load event.

<script>
    var chimpPopupLoader = document.createElement("script");
    chimpPopupLoader.src = '//s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js';
    chimpPopupLoader.setAttribute('data-dojo-config', 'usePlainJson: true, isDebug: false');

    function showMailingPopUp() {
        require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"XXXX","uuid":"XXXX","lid":"XXXX"}) })
        document.cookie = 'MCPopupClosed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;';
        document.cookie = 'MCPopupSubscribed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;';
    };

        
    jQuery(window).on("load", function() {
        document.body.appendChild(chimpPopupLoader);
        jQuery("#newsletter-signup--popup").click(function () { showMailingPopUp() });
    });
</script>
@gmmedia

This comment has been minimized.

Copy link

@gmmedia gmmedia commented Jun 13, 2018

Hello,
I use the Mailchimp ecomerce connection which comes with the same problems. This code also includes the popup.

The code looks like that.
<script id="mcjs">!function(c,h,i,m,p){m=c.createElement(h),p=c.getElementsByTagName(h)[0],m.async=1,m.src=i,p.parentNode.insertBefore(m,p)}(document,"script","https://chimpstatic.com/mcjs-connected/js/users/exxxxxxxxxxxxxxxe/exxxxxxxxxxxxxxxxxxxxxxxxc.js");</script>

Is there also a workaround for this script?

thanks
Jochen

@jaidy1luv

This comment has been minimized.

Copy link

@jaidy1luv jaidy1luv commented Jun 19, 2018

Hi,
Is there a way to add a placeholder to the popup form instead of the label above the input box?
I will like to remove the label and replace with placeholder instead

@frontenddevguy

This comment has been minimized.

Copy link

@frontenddevguy frontenddevguy commented Jun 22, 2018

Thanks, the original code wasn't working for me either.
This works a treat!

@mikeGski

This comment has been minimized.

Copy link

@mikeGski mikeGski commented Jun 23, 2018

If I put the code on my site... and it works... well, kind of. Say the page is fairly long (ie. goes below the "fold" and you need to scroll down)... the screen will "lock up" until I attempt to exit page... ie. the page wont allow me to scroll any more until I move the mouse towards the exit button on the page, let the pop up come up and then exit the pop up. Once I do that, then I can scroll on the page again. I have the mail chimp pop up settings in mailchimp set to on exit.

@williamyun7

This comment has been minimized.

Copy link

@williamyun7 williamyun7 commented Jun 28, 2018

@marcomarsala Thank you for your tip!

I experienced slow loading of embed.js with Amazon link but replacing it with //downloads.mailchimp.com/js/signup-forms/popup/embed.js , it takes less time to load the script!

@jerrysarcastic

This comment has been minimized.

Copy link

@jerrysarcastic jerrysarcastic commented Jul 5, 2018

This worked great for me. Props!

@mradulovic988

This comment has been minimized.

Copy link

@mradulovic988 mradulovic988 commented Jul 9, 2018

Man, thank you so much! You saved me

@agoedrich

This comment has been minimized.

Copy link

@agoedrich agoedrich commented Jul 12, 2018

Thanks for the script - it works great EXCEPT for... the popup window is glued to the header menu. It does not pop up in the middle of the page. I added the script to my child theme footer.php. I also tried the header and body as well with the same results. Any ideas?
screen shot 2018-07-12 at 11 21 56 am

@studiosally

This comment has been minimized.

Copy link

@studiosally studiosally commented Jul 13, 2018

Really thankful for your code and solution!! that helps me a lot :)

@LiangRenDev

This comment has been minimized.

Copy link

@LiangRenDev LiangRenDev commented Jul 18, 2018

Hi, @nickcernis, Thanks so much for the code, save me a lot of time. Only one question, why it conflicts if not placing on the very bottom of the page? I guess when executing require() function of mailchimp script, it will replace some global variable Jquery or Jquery UI used. Is that close to the right answer?

@lanastasov

This comment has been minimized.

Copy link

@lanastasov lanastasov commented Jul 19, 2018

How do you translate the pop up in another language? My site supports two languages and the pop up is displayed in one.

@ApoGouv

This comment has been minimized.

Copy link

@ApoGouv ApoGouv commented Jul 26, 2018

Finally it is working! Thanks @nickcernis and @BrunoBoehm

@roennfeldt

This comment has been minimized.

Copy link

@roennfeldt roennfeldt commented Aug 9, 2018

I'm having troubles with this script - getting a 404 error in the console. Can someone please identify where I've gone wrong?
Thanks!

Original code from MailChimp:

<script type="text/javascript" src="//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.us18.list-manage.com","uuid":"9eadeb17f89d31e84b9d05ac3","lid":"1abc12345a"}) })</script>

Code not working:

<script>
    // Fill in your MailChimp popup settings below.
    // These can be found in the original popup script from MailChimp.
    var mailchimpConfig = {
        baseUrl: 'mc.us18.list-manage.com',
        uuid: '9eadeb17f89d31e84b9d05ac3',
        lid: '1abc12345a'
    };
    
 // No edits below this line are required
    var chimpPopupLoader = document.createElement("script");
    chimpPopupLoader.src = '//downloads.mailchimp.com/js/signup-forms/popup/embed.js';
    chimpPopupLoader.setAttribute('data-dojo-config', 'usePlainJson: true, isDebug: false');

    var chimpPopup = document.createElement("script");
    chimpPopup.appendChild(document.createTextNode('require(["mojo/signup-forms/Loader"], function (L) { L.start({"baseUrl": "' +  mailchimpConfig.baseUrl + '", "uuid": "' + mailchimpConfig.uuid + '", "lid": "' + mailchimpConfig.lid + '"})});'));

    jQuery(function ($) {
        document.body.appendChild(chimpPopupLoader);

        $(window).load(function () {
            document.body.appendChild(chimpPopup);
        });

    });
</script>

Output URL with broken link:
https://mc.us18.list-manage.com/subscribe/form-settings?u=9eadeb17f89d31e84b9d05ac3&id=1abc12345a&u=9eadeb17f89d31e84b9d05ac3&id=1abc12345a&c=dojo_request_script_callbacks.dojo_request_script0

@tunners

This comment has been minimized.

Copy link

@tunners tunners commented Aug 9, 2018

This almost fixes the modal popup for me, except it's increasing the margins on the site before it pops up (adding a horizontal scroll) which return to normal when dimissed. I'm probably just going to post a link to the mailchimp sign up page unless i can get it sorted.

@roennfeldt

This comment has been minimized.

Copy link

@roennfeldt roennfeldt commented Aug 14, 2018

Hi @nickcernis, could you please have a really brief look at the above code and let me know if you see any errors I've made. Any help would be much appreciated!

@roennfeldt

This comment has been minimized.

Copy link

@roennfeldt roennfeldt commented Aug 14, 2018

This has been resolved - copied footer.php to child theme and put original embed code just before closing body tag. All working properly now!

@georgehee

This comment has been minimized.

Copy link

@georgehee georgehee commented Aug 20, 2018

great, works perfect! took me a whole day to find a correct solution on the web. you are the only one with a working solution. many thx!!!!

@buggles333

This comment has been minimized.

Copy link

@buggles333 buggles333 commented Aug 20, 2018

I am experiecning the same issue as @gmmedia as I use the connected site feature

@gmmedia - Did you manage to find a solution?

@nadiaaamand

This comment has been minimized.

Copy link

@nadiaaamand nadiaaamand commented Aug 28, 2018

This is brilliant. I do want to just put it out there how important it is to empty your cookies!

Been sitting for over an hour figuring out why this code doesn't work. Turns out it was my cookies..

Thanks for the fix :)

@swamyg

This comment has been minimized.

Copy link

@swamyg swamyg commented Oct 14, 2018

For anyone getting a require is not defined error, try this instead:

window.dojoRequire(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"YOUR_BASE_URL","uuid":"YOUR_UUID","lid":"THE_LIST_ID","uniqueMethods":true}) })

The difference here is using window.dojoRequire

@milli04

This comment has been minimized.

Copy link

@milli04 milli04 commented Feb 15, 2019

If anyone can help me on this it would be massively appreciated as I have come to a dead end. I have created a pop up in mailchimp and embedded to several different places on my site. they all work to the point where the pop up appears as it should, however when you fill in your details it always comes back with "there are errors below" the code I am using is

<script type="text/javascript" src="//downloads.mailchimp.com/js/signup-forms/popup/unique-methods/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">window.dojoRequire(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us12.list-manage.com","uuid":"1d4d24324773cb9de762ecf75","lid":"ee9591d795","uniqueMethods":true}) })</script>

I have tried embedding it to the home page, my header and footer all with the same result.

my site is https://jm-fit.com

@chadchester220

This comment has been minimized.

Copy link

@chadchester220 chadchester220 commented Feb 26, 2019

Just tried this hack with my Wordpress (OceanWP theme, Elementor), and in MailChimp it seems they changed their script, so doesn't work.

@axdlilli

This comment has been minimized.

Copy link

@axdlilli axdlilli commented Mar 21, 2019

If anyone can help me on this it would be massively appreciated as I have come to a dead end. I have created a pop up in mailchimp and embedded to several different places on my site. they all work to the point where the pop up appears as it should, however when you fill in your details it always comes back with "there are errors below" the code I am using is

<script type="text/javascript" src="//downloads.mailchimp.com/js/signup-forms/popup/unique-methods/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">window.dojoRequire(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us12.list-manage.com","uuid":"1d4d24324773cb9de762ecf75","lid":"ee9591d795","uniqueMethods":true}) })</script>

I have tried embedding it to the home page, my header and footer all with the same result.

my site is https://jm-fit.com

Hi @milli04, did you solve your issue yet? I've been having the same issue and nothing seems to help! Would appreciate tips on how to solve it?

@kimitrii

This comment has been minimized.

Copy link

@kimitrii kimitrii commented Mar 25, 2019

Can someone help me to fix a problem? I tried to implement this code at my Tumblr but something isn't work, look the code:

<html>
<head>
    
    <script type="text/javascript" src="//downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script>
<script>
function showMailingPopUp() {
  require(
    ["mojo/signup-forms/Loader"],
    function(L) {
      L.start({"baseUrl":"mc.us13.list-manage.com","uuid":"c8c472d7e369a7ed57444fbfb","lid":"b34aa88d1b"})
    }
  );

  document.cookie = 'MCPopupClosed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;';
  document.cookie = 'MCPopupSubscribed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;';
}
	
document.getElementById("open-popup").onclick = function() {showMailingPopUp()};
</script>


</head>

<body>
    <a onclick="showMailingPopUp(); return false;" id="open-popup" style="cursor:pointer">Subscribe!</a>
    
      <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  
  <!-- this script make the popup don't work -- ><script src="https://static.tumblr.com/xlsgtjb/mt5o305mz/scripts.min.js" charset="UTF-8"></script>

</body></html>

If I delete this script that make the popup don't work, the popup work, but the tumblr theme don't work at mobile. How can I fix it?

@khoipro

This comment has been minimized.

Copy link

@khoipro khoipro commented Feb 8, 2020

I placed a working code that works with any element that has class "open-subscribe".

<script>
      var mailchimpConfig = {
        baseUrl: 'mc.us100.list-manage.com',
        uuid: '__ca8d95c76d42a97b85f292ebf__',
        lid: '__8a953a7a64__'
      };
    var chimpPopupLoader = document.createElement("script");
    chimpPopupLoader.src = '//s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js';
    chimpPopupLoader.setAttribute('data-dojo-config', 'usePlainJson: true, isDebug: false');

    function showMailingPopUp() {
        require(["mojo/signup-forms/Loader"], function(L) { L.start(mailchimpConfig) })
        document.cookie = 'MCPopupClosed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;';
        document.cookie = 'MCPopupSubscribed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;';
    };

        
    jQuery(window).on("load", function() {
        document.body.appendChild(chimpPopupLoader);
        jQuery(".open-subscribe").click(function () { showMailingPopUp() });
    });
</script>
@khoipro

This comment has been minimized.

Copy link

@khoipro khoipro commented Feb 8, 2020

Have any other suggestion to disable popup when the page loaded? It was noisy and I wish to open a popup when I want.

@clausbv

This comment has been minimized.

Copy link

@clausbv clausbv commented Feb 10, 2020

I placed a working code that works with any element that has class "open-subscribe".

<script>
      var mailchimpConfig = {
        baseUrl: 'mc.us100.list-manage.com',
        uuid: '__ca8d95c76d42a97b85f292ebf__',
        lid: '__8a953a7a64__'
      };
    var chimpPopupLoader = document.createElement("script");
    chimpPopupLoader.src = '//s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js';
    chimpPopupLoader.setAttribute('data-dojo-config', 'usePlainJson: true, isDebug: false');

    function showMailingPopUp() {
        require(["mojo/signup-forms/Loader"], function(L) { L.start(mailchimpConfig) })
        document.cookie = 'MCPopupClosed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;';
        document.cookie = 'MCPopupSubscribed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;';
    };

        
    jQuery(window).on("load", function() {
        document.body.appendChild(chimpPopupLoader);
        jQuery(".open-subscribe").click(function () { showMailingPopUp() });
    });
</script>

Where do I need to add this code in order to work?

@khoipro

This comment has been minimized.

Copy link

@khoipro khoipro commented Apr 6, 2020

Install plugin: Insert Headers and Footers

Add it to before body ending.

@gaborpeter

This comment has been minimized.

Copy link

@gaborpeter gaborpeter commented Jun 16, 2020

This was the only solution that worked on Drupal also.
Thanks, well done

@mauirinho

This comment has been minimized.

Copy link

@mauirinho mauirinho commented Jun 16, 2020

Hi everybody,
i have a problem with my prestashop 1.7.6.4 and mailchimp popup.
i have installed module v2.0.5 di Mailchimp.
Today i have this error, i don't know why today yes and yesterday no. The site has never changed in 1 month.
I put this code in header for manage popup mailchimp form subscribe to show it only where and when i want. This is the code:

window.dojoRequire(["mojo/signup-forms/Loader"], function(L) { L.start({
"baseUrl":"mc.us15.list-manage.com",
"uuid":"xxxxxxxxxxxxxxx",
"lid":"yyyyyyyyyyy",
"uniqueMethods":true})
});

but i receive always this error on Chrome's console:
Uncaught TypeError: window.dojoRequire is not a function

can someone help me?

please...

thank's in advance

maui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.