SOLVED

Known Visitor HTML + Redirect Javascript

Go to solution
jsiebert
Level 5

Known Visitor HTML + Redirect Javascript

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? 

Jack Siebert
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Known Visitor HTML + Redirect Javascript

Not clear what you’re asking.

 

  • KV HTML doesn’t affect custom onSuccess listeners (it does affect onSubmit listeners).
  • If you have more than one onSuccess listener, they’ll fire in the order added.
  • If either listener redirects, the page will redirect, even if the first listener tried to stay on the page.
  • If both listeners redirect, you will not necessarily end up on the second listener’s destination page, however, because that depends on network and server conditions.*

 

 

 

* 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!)

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Known Visitor HTML + Redirect Javascript

Not clear what you’re asking.

 

  • KV HTML doesn’t affect custom onSuccess listeners (it does affect onSubmit listeners).
  • If you have more than one onSuccess listener, they’ll fire in the order added.
  • If either listener redirects, the page will redirect, even if the first listener tried to stay on the page.
  • If both listeners redirect, you will not necessarily end up on the second listener’s destination page, however, because that depends on network and server conditions.*

 

 

 

* 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!)

jsiebert
Level 5

Re: Known Visitor HTML + Redirect Javascript

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!

Jack Siebert