Google tag manager variable for checked radio button does is always undefined
-
We have successfully integrated the plugin with our mailchimp account and created a sign up form (custom integration) with an email field and some radio buttons. We are trying to pass the value of the radio button the user checked to the data layer using Tag Manager using this guide, https://www.mc4wp.com/kb/google-tag-manager-tracking/, but while the tag fires up and the form name and id passes to the data layer, the variable for the checkbox value does not. If we set a default value for the checkboxes the value passes successfully. This is our code below the form.
<script type="text/javascript"> jQuery('.radio-box').on('click',function(){ jQuery(this).attr('checked', 'checked'); }); mc4wp.forms.on('started', function(form) { var radioName = "MMERGE6"; var checked = document.querySelector('[name="' + radioName + '"]:checked').value; window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event' : 'Sign-up', 'name' : form.name + ' ID: ' + form.id, 'checked' : checked}); }); </script>
The page I need help with: [log in to see the link]
- The topic ‘Google tag manager variable for checked radio button does is always undefined’ is closed to new replies.