I have a site with submit form that consists of 4 steps. User moves from step to step via JavaScript sort of like this:
<div id="step1">
</div>
<div id="step2">
</div>
<div id="step3">
</div>
<div id="step4">
</div>
Steps 2,3,4 are hidden initially. When user goes to step 2, step 1 is hidden, and step 2 is shown.
Problem is, I need to load Google Tag Manager code on step 2. But if I just paste Tag Manager code on page at <head> tag, it will get loaded on any step which is not good for me.
So is there a way to load Tag manager only on step 2, or just not load it at step 1.
Code looks like this
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id="
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','');</script>
<!-- End Google Tag Manager -->
headusing jQuery, when step 2 is shown.