Re: Where to put the Google Tag Manager code on a Marketo Landing Page Template?

Anonymous
Not applicable

Where to put the Google Tag Manager code on a Marketo Landing Page Template?

We are using Google Tag Manager to organize and maintain any 3rd party scripts that need to go on our website and on our Marketo Landing pages. I am trying to figure out what the best option is for placement for the GTM code in a Marketo Landing Page Template. I have found a number of articles on how to put the Marketo Munchkin in a GTM, but nothing addressing best placement in a Marketo LP Template. What is the best practice, where do you put the Google Tag Manager code snippet in your Marketo Landing Page Templates?

GTM suggests right after the opening <body> tag, which would put it about here in our template:

</head>

<body id="bodyId" class="mktEditable" align="center">

<!-- Google Tag Manager -->

<noscript><iframe src="//www.googletagmanager.com/ns.html?id=YOUR GTM CONTAINER 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','YOUR GTM CONTAINER ID');</script>

<!-- End Google Tag Manager -->

<div id="outerWrapDiv">

<div id="headerWrap">

<div id="mktHeader" class="mktEditable">

  <!-- Logo and Header -->

But I have also heard some people saying to put it in the area where you would normally put the GA code snippet which would be just above the closing </body> tag:

</div>

<!-- GOOGLE ANALYTICS.  ENTER YOUR CODE and UNCOMMENT block -->

<!--

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">

</script>

<script type="text/javascript">

_uacct = "YOURCODE";

urchinTracker();

</script>

-->

</body>

4 REPLIES 4
Grégoire_Miche2
Level 10

Re: Where to put the Google Tag Manager code on a Marketo Landing Page Template?

I would follow Google recommendation on this.

-Greg

Anonymous
Not applicable

Re: Where to put the Google Tag Manager code on a Marketo Landing Page Template?

I usually put these in the footer.

Grégoire_Miche2
Level 10

Re: Where to put the Google Tag Manager code on a Marketo Landing Page Template?

Hi Jamie,

My understanding is that the footer, just before the </body> tag is good for Google Analytics, but not recommended for GTM.

-Greg

SanfordWhiteman
Level 10 - Community Moderator

Re: Where to put the Google Tag Manager code on a Marketo Landing Page Template?

Yes, follow the Google recommendation (if you must use GTM).

The JS variant (the one the vast majority of your leads will be invoking) injects an asynchronous script tag.  You want this process to begin as high up as possible.