I have the standard Mailchimp pop up embedded on my site. I would like to trigger a GTM event every time it's submitted to send to GA. It's an embedded iframe and I'm not seeing a way to handle this. This is the embed code for the pop up:
<script id="mcjs">!function(c,h,i,m,p){m=c.createElement(h),p=c.getElementsByTagName(h)[0],m.async=1,m.src=i,p.parentNode.insertBefore(m,p)}(document,"script","https://chimpstatic.com/mcjs-connected/js/users/xxxx/xxxx.js");</script>
I've tried reviewing the form class, form element and other form triggers, but nothing is triggering the GTM event.
GTM's "Form Submission" trigger cannot catch form submissions in (embedded) iframes.
If you are only interested in the submit, you can add a custom event listener via a "Custom HTML" tag which pushes a custom event to dataLayer which you can then act on in GTM.
document.querySelector('#PopupSignupForm_0 div.mc-modal iframe').contentDocument.querySelector('form').addEventListener('submit', function(event){dataLayer.push({event: 'mailchimp_submit'})});
This triggers every time the "subscribe" button is clicked - also when the form does not validate.
Maybe it is better to use a Timer trigger which checks for a "MCPopupSubscribed" cookie with the value "yes"?
Create a Variable "MCPopupSubscribed", 1st Party Cookie, Cookie Name: "MCPopupSubscribed", Format Value: Convert undefined to "no"
Create a Variable "TimerID", Data Layer Variable, "gtm.timerId", Version 2
Create a Trigger "Mailchimp", Timer, Event Name: "gtm.timer", Interval: 1000, Enable ...: MCPopupSubscribed does not equal yes, Fires on some timers: MCPopupSubscribed equals yes
Create your tag, fires on "Mailchimp" trigger
Create a Tag "Clear Timer", Custom HTML, fires on "Mailchimp" trigger
if ({{TimerID}}) {
window.clearInterval({{TimerID}});
}
The Timer will only "run" if the cookie is absent. It then checks every second if the cookie was set. If it is set it runs your tag and it runs "Clear Timer" to stop the timer/trigger. If it the timer is not stopped the trigger keeps firing every second.
There's also a cookie MCPopupClosed=yes which is set if the user closes the popup...
I've noticed that the GA4 events are fired in delay (about 1 sec after universal analytics fires)
This is ok as long as the event fires, but when the event is click on redirection link, the pages are redirected before the GA4 event fires (universal analytics is ok)
anyone knows anything about it?
I'm using GTM to store the event detail, and the click element has a unique id (data-attribute)
You can set tag firing prioritization, in your scenario keep GA4 tag at first priority.
Know more: https://support.google.com/tagmanager/answer/2772421?hl=en
I'm running into an issue for a form submission event firing too often (200x). The trigger for the event is created from the GTM standard Trigger Type of "Form Submission" where we're checking validation and have specified the conditions to be only on the Page URL where the form exists. We've tested it in GTM preview mode and seeing that the event fires.
Update 1/28-
The form is on a pop-up through our homepage (https://mybrightwheel.com) after the user clicks on "Request a Demo" (so the event fire should not happen on this initial button click). The event fire should occur after they get into the demo request form and complete a successful form submit. And below that is a shot of the trigger. Any help here is appreciated.
That trigger hasn't specified which button it's firing on. You have 2 buttons in that screenshot, it's recording both. You need to tell it to fire on one button or the other by specifying link text or link url (i.e. where the user ends up on clicking the link)
I have a page with search button, and an tag event that should be fired when the button is pressed.
My question is if the loading of the new page (that should be displayed when the 'search' button is pressed) will be delayed until after the code in the tag event is finished, or is it done asynchronously somehow
default loading of the new page will be delayed until after the code in the tag event is finished. Tags are usually fired as a listener to click event and they're executed before the default action. However, if your search button has some custom listener that redirects to a new page and overrides the default action then tag may not fire correctly.
I have defined a trigger having event name as "gtmEvent" and a tag "AccountCreated". When I click on a button ("createAccount") it goes to next page. But tag is not fired and also in summary the event is not listed but when i check google analytics through console i found that tag is there in event name.
Is it when you click on page and after clicking you stayed at same page only then the event listed on summary otherwise it will lost. ??