Last active
September 10, 2018 19:26
-
-
Save tammalee/03d7feb2317affbcffc97ff196512f9d to your computer and use it in GitHub Desktop.
MailChimp 4 WordPress GTM data layer push after form submission
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Hooking into MailChimp for WordPress | |
* MC4WP JS Form Events: https://mc4wp.com/kb/javascript-form-events/ | |
* Form success | |
*/ | |
(function($) { | |
$(document).ready(function() { | |
mc4wp.forms.on('748.success', function(form) { | |
//GTM Data Layer Code Goes Here | |
window.dataLayer = window.dataLayer || []; | |
window.dataLayer.push({ | |
'event' : 'formSubmissionSuccess', | |
'formId' : 'newsletterForm' | |
}); | |
}); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah hello! I hadn't realized I had a comment. This is far too late to be of use to you, I'm sure, but I usually put that code in its own js file. As far as I know, this code still works with the MailChimp 4 WordPress plugin.