Launching a Mailchimp popup from a menu item
I'm trying to add a menu item that when clicked, will open a Mailchimp popup form. Although I'm familiar with VBA and Access Dev, I have limited knowledge of Web/WordPress Dev.
These are the snippets of code I've tried so far based on the research I've done online:
1) I found this one on several different sites. The problem with it is that it seems there isn't any way to get it to launch from a Menu item.
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"
function showPopup() {
window.dojoRequire(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us20.list-manage.com","uuid":"YOUR_UUID_GOES_HERE","lid":"YOUR_LID_GOES_HERE","uniqueMethods":true}) });
//unsetting the cookie
document.cookie = "MCPopupClosed=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
document.cookie = "MCPopupSubscribed=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
}
document.getElementById("show-popup").onclick = function() { showPopup(); }
/script
2) This is the second one I've tried.
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"
jQuery(document).ready(function($) {
$("menu-item-364").on("click",function showPopup() {
window.dojoRequire(["mojo/signup-forms/Loader"], function(L) {
e.preventDefault();
L.start({"baseUrl":"mc.us20.list-manage.com","uuid":"YOUR_UUID_GOES_HERE","lid":"YOUR_LID_GOES_HERE","uniqueMethods":true}) });
////unsetting the cookie
document.cookie = "MCPopupClosed=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
document.cookie = "MCPopupSubscribed=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
});
});
document.getElementById("show-popup").onclick = function() { showPopup(); }
I also read another post where someone recommended using the addEventListener onhashchange event to launch the function and a) I wasn't able to get it to work and b) I have a concern that it would then launch anytime the hashtag changes - causing issues if I use anchors to navigate in other areas of the site in the future.
What am I missing?
Topic plugin-mailchimp Wordpress
Category Web