• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
rahmanzeb.com

rahmanzeb.com

Rahman Zeb's Portfolio & Blog

  • Home
  • About
  • Tutorials
    • Google Sites Tutorials
    • WordPress Tutorials
    • CSS Tutorials
  • Templates
    • Google Sites Templates
  • Portfolio
  • Hire me!
  • Contacts

How to make mailchimp’s popup window appear with a click only?

06/05/2016 By Rahman Zeb 24 Comments

Here is a step by step tutorial about how to make mailchimp’s popup appear with click on a button or link.

Mailchimp’s default pop up code appears either immediately after loading or after a few seconds as set by you at the admin panel in mailchimp, but if you want to make the mailchimp’s pop-up to appear with a click on a button or a link then the following tutorial will show you how to do that.

First login to your mailchimp acccount and then click on the Audience button and then select the Signup Forms and then click on the Subscriber pop-up or click on the select button next to it. From the settings on the left set Display to immediately so the pop up shows straight away when somebody clicks on the button.

Before they give you the code you have to connect your website first. For that reason they will give you the code which you will have to put in the header so it can find it and verify it. After you are done now is the time to play with the code and make it work the way we want it to work, i.e. to make mailchimp’s popup appear with a click on a button or link with a specific id.

If you have the code, fine! if you haven’t or you want it again then click on the Edit button at the top and then Manage Connected Sites and there click on the Site Code to access site code. Your code will look something like this.

<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/9f0ff62a247e302836e834a77/d986f27b70963c46c0ce59ec7.js");</script>

By default mailchimp gives you the above code but it doesn’t do anything and it will just automatically appears if you put it in your site straight away. So you’ll have to use the following code in order to make the mailchimp popup windows appear on click only.

<script id="mcjs">
function showPopup() { 
    !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/9f0ff62a247e302836e834a77/d986f27b70963c46c0ce59ec7.js");

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

In the above code the function has been wrapped in a function showPopup() and it will be called when someone clicks on an element with the id of show-popup. And on the last line of above function we are expiring the cookie so the form appears every time when someone clicks on that element.

make mailchimp's popup appear with a click on a button or link
Click on the Audience tab after login to mailchimp.
make mailchimp's popup appear with a click on a button or link
Click on the subscriber pop-up inside the signup forms window
make mailchimp's popup appear with a click on a button or link
Click on the Edit > Manage connected sites to get the code
make mailchimp's popup appear with a click on a button or link
Click on the Site Code or View Code to see the code.
make mailchimp's popup appear with a click on a button or link
View Code of subscriber pop-up on mailchimp’s admin panel

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on LinkedIn (Opens in new window) LinkedIn

Filed Under: Uncategorized

About Rahman Zeb

Rahman Zeb is a passionate freelance web designer and developer and loves creating awesome and interactive websites. Beside Web design and development he loves to play cricket and badminton with his friends.

Reader Interactions

Comments

  1. meneguzzo68 says

    16/03/2023 at 12:28 pm

    HI!

    I have seen that in this page (soure code of this page) you do not use

    document.getElementById(“show-popup”).onclick = function() { showPopup(); }

    is it required ?

    Reply
    • Rahman Zeb says

      16/06/2023 at 11:10 am

      Yes it is, it will actually call the function on click.

      Reply
  2. Jenna says

    14/05/2022 at 10:40 pm

    Good evening!

    I have been trying and trying and somehow my button won’t do anything when I click on it (I’ve also tried it with just a text but that wasn’t doing anything either). I was hoping you could help me? The button can be found on https://hopefulhome.co.uk/uk-seasonal-food-chart. It’s a landing page that has been made with the help of Seedprod so the buttons are already given id’s. So I’ve changed the open-popup text in your code to #sp-m2i87n (I also tried it without the hashtag). I’ve had to add your entire code into the ‘Insert headers and footers’-plugin and I’ve changed the https link in your code to the one Mailchimp gave me. What am I doing wrong? Getting slightly desperate now! I hope you can help me.

    Jenna

    Reply
    • Rahman Zeb says

      05/06/2022 at 12:28 am

      Good Evening!

      Just add a button and then add the code and then let me know and I’ll check and help you with whatever you are doing wrong.

      Reply
  3. Mindy Iannelli says

    05/02/2022 at 2:43 am

    This is great and works perfectly, thank you! Now I’m trying to make the popup redirect to a custom thank you page instead of showing the SUCCESS on the pop up. I can redirect an embedded form, why not a pop up? Do you know how to do this? Thanks!

    Reply
  4. M.Mehran says

    15/10/2021 at 10:24 pm

    Hi Rahman Zeb!

    i am facing the issue that when i am login in wordpress the popup is working, but when i logout from wordpress it’s not working the popup?

    please help me out it’s urgent.

    Thank you.

    Reply
    • Rahman Zeb says

      24/11/2021 at 7:46 am

      Just share the url of the site with me and I’ll check it for you.

      Reply
  5. littlebutty says

    16/05/2020 at 7:16 am

    Your script assumes everyone is in the `us20` location for mailchimp and in my case I was not. You may want to add one for step in addition to copying the UUID and LID and also copy the subdomain of the baseURL:
    mc.us20.list-manage.com

    Reply
    • Rahman Zeb says

      16/05/2020 at 11:22 am

      Yeah you are right and the easiest way would be to put that whole script or code inside the second script tag you got from the mailchimp inside that function and you’ll be fine.

      Reply
  6. brianlrollo says

    29/04/2020 at 6:43 pm

    Interesting – I added the ID to my link and entered the code into my footer. On click the form appears but then quickly disappears. Scratching my head on this one. Any clues as to what might be wrong?

    Reply
    • Rahman Zeb says

      16/05/2020 at 11:23 am

      Can you kindly share with me your website url where you are implementing this.

      Reply
      • M.Mehran says

        15/10/2021 at 10:27 pm

        Hi Rahman Zeb!

        i am facing the issue that when i am login in wordpress the popup is working, but when i logout from wordpress it’s not working the popup?

        Please help me out It’s urgent.

        Thank you

        Reply
  7. omarco says

    04/09/2018 at 2:36 pm

    Hi Rahman Zeb,

    I am using wordpress to create my website which is pretty much finished. Where do I copy the code for the button to? Also where do I copy the code in wordpress that mailchimp provided me for the popup form? I am very confused as coding is not my strongest skill.
    Please help a brother out,

    Cheers

    -omarco

    Reply
    • Rahman Zeb says

      16/10/2018 at 12:03 pm

      Hey Omarco,

      You gotta use wp_enqueue_script function in order to embed the code that mailchimp gives you. And I’ll edit this blog soon to include that step for people like you so they can easily embed it in their sites and some themes by default comes with a box where you can easily copy/paste your code. And for wp_enqueue_script reference please check the following link.
      https://developer.wordpress.org/reference/functions/wp_enqueue_script/

      And anyway thanks for pointing it out, I’ll soon make it helpful for people like you.

      Reply
  8. Luca of Creative Enabler says

    19/08/2018 at 2:30 pm

    Thank you for this detailed post. Perfecto!

    Reply
  9. BostonMurrell says

    25/05/2018 at 11:27 am

    Hello
    This is not working

    Reply
    • Rahman Zeb says

      28/05/2018 at 10:11 am

      Hello Boston,

      It is working and I did it myself, you might be doing something wrong.

      Reply
  10. Jay says

    17/04/2018 at 6:16 am

    Hi there! I was wondering if it was possible to link the pop up to an image rather than a button?

    Reply
    • Rahman Zeb says

      17/04/2018 at 8:47 am

      Yeah just give it an of “open-popup” and it will work.

      Reply
  11. Letitia McQuade says

    04/03/2018 at 3:33 am

    This is fantastic, but I still don’t know how to get it to pop up…. you missed out the last step… how do I link the code to a button??/

    Reply
    • Rahman Zeb says

      04/03/2018 at 7:34 am

      Just create a button with an id of open-popup and it will work. Other than that if there is anything else please do not hesitate to ask me.

      Reply
      • exampleK says

        10/04/2018 at 2:59 am

        Thanks for making this post!
        If I’m linking the pop up to a Call to Action button, what would I put in as the Button Link?

        Reply
        • Rahman Zeb says

          11/04/2018 at 9:32 am

          just give that call to action button an id and replace “open-popup” in document.getElementById(“open-popup”) with your id and it should work.

          Reply
          • emilie says

            21/10/2018 at 8:32 am

            So just to clarify we leave the button link section lank and in the css id we put the “open-popup” id?

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Hire Me

zebkhan
Fiverr
Seller
I'm web designer and developer and an expert in languages like html, css, javascript, php & mysql. I also know Joomla & Wordpress and have designed and developed dozens of sites. Most of the sites I have designed were responsive.

Follow Me

  • Facebook
  • X
  • Google
  • LinkedIn
  • Pinterest

Top Posts & Pages

  • How to add click to Call button in google sites
    How to add click to Call button in google sites
  • Google Sites Templates
    Google Sites Templates
  • Make an image scroll from top to bottom on hover
    Make an image scroll from top to bottom on hover
  • How to add typing text effect in Google Sites
    How to add typing text effect in Google Sites

Main Menu

  • Home
  • About
  • Tutorials
    • Google Sites Tutorials
    • WordPress Tutorials
    • CSS Tutorials
  • Templates
    • Google Sites Templates
  • Portfolio
  • Hire me!
  • Contacts

Footer

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 239 other subscribers

Recent Posts

  • How to add typing text effect in Google Sites
  • Top 3 Custom Forms you can use in Google sites instead of google forms for free
  • Add click to chat on WhatsApp & facebook buttons or links in google sites
  • How to add video background in Google Sites
  • Make an image scroll from top to bottom on hover

Best Web Hosting

BlueHost SiteGround iPage Godaddy

Created with Genesis Framework on Wordpress and hosted by BlueHost

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPT
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT