Hi!
I’ve been trying to make a Mailchimp ‘subscribe’ pop-up work ‘on click’ (yep, I really dislike automatic pop-ups), but no luck… anyone with tips on how to make it work on a Jekyll Blog?
(btw, ignore the horrible looking “Join Newsletter” button. It is there for testing purposes )
This is my repo:
This is the site:
1) First I’ve made the pop-up work automatically (this works).
This is the code coming from Mailchimp (this works, but the pop-up shows up upon site load, i.e. automatically):
<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.us12.list-manage.com","uuid":"myuuid","lid":"mylid"}) })</script>
I’ve added this code to a newsletter.html in ‘_includes’ and then {% include newsletter.html %}
to default.html.
The above works, and the pop-up will pop-up automatically.
2) Willing to make the subscribe form pop-up on click, I’ve followed this:
And added a bad-looking button to the navigation bar with the following added to masthead.html
<button id="open-popup" onclick ="showMailingPopUp(); return false;">Join Newsletter</button>
I’ve then modified newsletter.html to:
<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.us12.list-manage.com","uuid":"myuuid","lid":"mylid"}) }) })
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>
And I’ve continued including newsletter.html by adding {% include newsletter.html %}
to default.html.
But 2) doesn’t work, any pointers?