简体   繁体   中英

Google Tag Manager Form - Thank You Page

I am trying to use google tag manager to have a tag that will fire every time the user submits the form and lands on the thank you page. In this scenario, I know an option is to use the Trigger: Page View, and then specify the thank you page URL in the conditional statement.

However, since this URL can be shared, I only want to track when the user submits the form and lands on the thank you page (not when the URL is accessed through other ways). What would be the best way to tackle this?

Why would people share the thank-you page? I can imagine sharing a form, but why would the url of the Thank you page get shared.

However, what you can do is track clicks on the button or link that submits the form.

I ll advise assuming you NEED to fire when the user gets to the ThankYou Page for X reason and CANT be done on the button submit click. Add a custom HTML tag with a trigger on the click of the form submit button (you can use build in variables such as Click Classes) and add a 'flag' on the session storage or a cookie (choose the one you are more comfortable with). Then generate a trigger that fires on the Thankyou page AND has the flag on.

Example:

Tag when user submit the form:

<script>
storage.setItem('flagSubmit', 1);
</script>

Custom JS variable that checks if user has flag:

function(){
    return storage.getItem('flagSubmit');
}

If you need any more help just ask. Hope it helps!

-- EDIT: add info

As you comment you cant detect if the flag is being saved properly so here is a code you can paste on the console that ll avoid you browser to exiting the page and allowing you to see if your click tag worked and registered on session storage you data.

window.addEventListener("beforeunload", function() { debugger; }, false)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM