4

I'm using MailChimp and I want to display the sign up form on a button click. They provide a modal pop up but it only loads when the page loads or after x amount of secs.

I want to display the screen only when a user clicks a button. Can anyone lead me the right way?

This is the code I get from MailChimp.

<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.us12.list-manage.com","uuid":"5fa6528f19f668f9c0c842dab","lid":"5319bf6b62"}) })</script>

Thanks!

gnr5
  • 55
  • 2
  • 7

2 Answers2

0

Try this:

<!-- This is the HTML element that, when clicked, will cause the popup to appear. -->

<button id="open-popup">Subscribe to our mailing list</button>



<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>
function showMailingPopUp() {
require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us11.list-manage.com","uuid":"YOUR_UUID_GOES_HERE","lid":"YOUR_LID_GOES_HERE"}) })
document.cookie = "MCEvilPopupClosed=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
};

document.getElementById("open-popup").onclick = function() {showMailingPopUp()};
</script>

Just make sure to update the "mc.us11.list-manage.com" the "uuid" and the "lid" to match what mailchimp gives you.

Rick
  • 114
  • 1
  • 12
0

After a lot of reserch I found the solution.

in my case just add 2 lines for removing cookies after onclick function body

<script type="text/javascript" charset="utf-8" src="//downloads.mailchimp.com/js/signup-forms/popup/1.0/popup.js"></script>
<script src="//s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script>

function openPOPUP(){ 
 require(["mojo/signup-forms/Loader"], function (L) { L.start({"baseUrl": "mc.us18.list-manage.com", "uuid": "YOUR UUID", "lid": "YOUR LID"})}); 
 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";
 }

<input type="button" onclick="openPOPUP();" value="Subscribe" id="button-color" class="newslatter-new">