When moving hardcoded tags into GTM, the hard code can be replaced with an event named <tagPostion>_<vendorName>_<trackerType> for example:

 

<!– GA PAGEVIEW tracker WAS here moved into GoogleTagManager –>

<script>
window.dataLayer = window.dataLayer || [];

dataLayer.push({“event”: “onload_ga_pageview”});

</script>

 

Then a rule needs to be added into GTM to trigger this tag above.

The advantage of this method is that it means that when the old code is replaced with GTM it works seamlessly, and developers just need to find and replace 🙂

***

IMPORTANT: if both the legacy GA code and an onload {{Event}} trigger are active on a page, then the pageview will trigger TWICE! This is because GTM logic uses an either-or rule. Hence, remember to replace the GA code with dataLayer.push({“event”: “onload_ga_pageview”});

***

Note: It is possible to add a pageview blocking rule to prevent double firing, if the GA classic {{_gaq}} variable is defined, but this is not a 100% reliable solution; as some 3rd party plugins will declare _gaq. See this post for details.

***

The same method applies to DoubleClick code, except page specific values can also be passed in:

<!– DoubleClick COUNTER was here – moved into GoogleTagManager

Creation Date: 01/01/2014 –>

<script>
window.dataLayer = window.dataLayer || [];

dataLayer.push({

“event”: “onload_doubleclick_counter”,

“src”: “3018669“,

“type”: “atter993“,

“cat”: “ithom544“,

“ord”: “1“});

</script>

image077

0117 3361103