Skip to content

Instantly share code, notes, and snippets.

@kjy112
Last active October 26, 2017 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjy112/808324fded06824b45193e1be0f19241 to your computer and use it in GitHub Desktop.
Save kjy112/808324fded06824b45193e1be0f19241 to your computer and use it in GitHub Desktop.
/* Using JQuery. In MailChimp case, since they assigned jQuery to $mcj
* var $mcj = jQuery.noConflict(true);
* replace jQuery with $mcj for best practice
*/
jQuery('#mce-success-response').bind("DOMSubtreeModified", function() {
/* Do whatever you wish upon successful email submission */
/* Setup Google Analytics Conversion Tracking */
ga('send', {
hitType: 'event',
eventCategory: 'MailChimp',
eventAction: 'Email Submit',
eventLabel: 'Fall Campaign'
});
/* Redirect to a link of your choice with setTimeout */
setTimeout(function() {
window.open('http://google.com', '_blank');
}, 3000);
});
/* Pure JavaScript version */
document.getElementById('mce-success-response').addEventListener("DOMSubtreeModified", function() {
/* Do whatever you wish upon successful email submission */
/* Setup Google Analytics Conversion Tracking */
ga('send', {
hitType: 'event',
eventCategory: 'MailChimp',
eventAction: 'Email Submit',
eventLabel: 'Fall Campaign'
});
/* Redirect to a link of your choice with setTimeout */
setTimeout(function() {
window.open('http://google.com', '_blank');
}, 3000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment