Hi, community!
I am working on adding Google Analytics 4 tags to our forms to track form submissions per form using this article (https://www.dreweastmead.com/blog/how-to-pass-marketo-form-submissions-through-gtm-into-ga4). The tags work properly on all of our forms except for our forms that we use for downloading content on our site. For these forms, we use known visitor HTML because every form uses the same Marketo form + some custom javascript to redirect to the correct page.
It appears that once we implement these tracking tags in tag manager, the known visitor HTML overrides the Javascript and there is no redirect anymore. When I turn off the GA4 tag, the known visitor HTML form redirects successfully. Here is what my Javascript code looks like for the content downloads:
<script src="//Marketo Script Source"></script>
<form id="Marketo Form"></form>
<script>MktoForms2.loadForm("//Site", "Munchkin ID", Form Name, function(form) {
form.onSuccess(function(values, followUpUrl) {
location.href = "Redirect Site URL Goes Here";
return false;
});
});</script>
Does anyone have any experience with tag manager overriding Known Visitor HTML or custom Javascript?
Solved! Go to Solution.
Not clear what you’re asking.
onSuccess
listeners (it does affect onSubmit
listeners).onSuccess
listener, they’ll fire in the order added.
* e.g. if you redirect to URL 1 and then URL 2, if URL 1 is lighting-fast and URL 2 is slow, you’ll end up on URL 1. If they have the same performance, you’ll end up on URL 2 . You don’t want to have this kind of race condition as it’s incredibly confusing!)
Not clear what you’re asking.
onSuccess
listeners (it does affect onSubmit
listeners).onSuccess
listener, they’ll fire in the order added.
* e.g. if you redirect to URL 1 and then URL 2, if URL 1 is lighting-fast and URL 2 is slow, you’ll end up on URL 1. If they have the same performance, you’ll end up on URL 2 . You don’t want to have this kind of race condition as it’s incredibly confusing!)
My tags were using the onSuccess event and causing this race condition. This makes sense being something I want to avoid. I have a better idea on what to do now - thanks @SanfordWhiteman!