x

Best practice for implementing GTM

What's the best way to implement Google Tag Manager? Latest GTM requires one code snippet to sit globally within <head> tags and the 2nd code snippet to sit globally on every page, immediately after the opening <body> tag.

What is the best practice for adding the 2nd code snippet to <body> section of every page?

7,610 Views
Message 1 of 21
Report
20 REPLIES 20
Square

For the code that needs to go between the <head> tags, add that to Settings > SEO > Header Code.  For code that needs to go at the top of a page under the <body> tag, add it to the page using the Embed Code element above all your other content.

7,584 Views
Message 2 of 21
Report

The last sentence does not make sense to me. Google Tag Manager asks us to "Additionally, paste this code immediately after the opening <body> tag:"

I went to my Weebly website's Settings > SEO page. I see a block labeled "header" and "footer," and I understand what to put there. I know that I can get the Embed Code element from Weebly's Build and I understand how to add it to a "real" page's design, but I do not see how to add an Embed Code to the Settings > SEO page. 

Do you mean that we should drag it and add it to the content of a "real" page? Won't everybody see it there?

You guys usually provide very helpful and clear answers, but this one has me stumped~~ thanks for explaining what you mean again.

7,371 Views
Message 2 of 21
Report

No worries, MAcevedo!

You have the basics right. The "Body" section of the site in a Weebly site is where you drag elements and content. If you drag an Embed Code element onto the page, and paste the code there, it will be placed in the Body section. Code doesn't appear visibly the same way plain text does, and analytics code like this shouldn't appear at all.

7,367 Views
Message 2 of 21
Report

Adam, how about on the /blog/ page?   My blog page is set up to just show a snippet of each post.  There doesn't appear to be anywhere on that page where I can drop an embed tag.

Thanks,

Trisha

7,211 Views
Message 2 of 21
Report
Square

For the blog, you'd probably need to customize the HTML of whichever page type the blog page uses (this would also add it to any other page of the site using the same page type).  You can do that by going to the Theme tab, click Edit HTML / CSS, then clicking on the appropriate page template to the left.

7,209 Views
Message 2 of 21
Report

In my Weebly site, with regard to the second snippet that goes directly after the body tag, that appears only available on Theme where I then can edit the HTML. So I have 4 pages within the website - but only need to add that second snippet to the theme in one place? 

7,154 Views
Message 2 of 21
Report

Adam, I already have the code for Google Analytics in the Header Code box in the SEO section of Settings... now Google wants me to install a tag for phone number click tracking, can 2 codes exist in the same Header box?

5,678 Views
Message 2 of 21
Report
Square

Hi @monaghan1976. Yes, you can have mulitple codes in the header and footer section. Smiley Happy

5,673 Views
Message 2 of 21
Report

So if I am doing an google analytics tag and a phone tracking tag in the Header section of the SEO Settings, would I just stack them on top of each other like this?

<script>

  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){

  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)

  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'XX-1234567891-1', 'auto');

  ga('send', 'pageview');

</script>

<script>

  gtag('config', 'XX-123456789/abdcefg1a2-av1ab', {

    'phone_conversion_number': 555-555-1212'

  });

</script>

5,665 Views
Message 2 of 21
Report
Square

Hm.. never heard of a phone tracking script, but yes, that is how you would do it. I like to keep a space or 2 between them to keep it easy to manage. 

2,965 Views
Message 2 of 21
Report

I'm so sorry, but I still don't get it... it shows only a header and footer place to put the code... so where do I put the body tag? is that just for additional pages... not the home page?  Sorry I'm such a neophyte...

Bonnie

2,852 Views
Message 2 of 21
Report
Square

It's ok, @Bonnie1 - it's not always clear from directions where to place things. Does it say to put it right before the closing body tag? If so, add it to the Footer Code field. If it says to put it in the Head area then add it to the Header Code field.

2,849 Views
Message 2 of 21
Report

Hi Adam,

I've read several of these threads as well as outside blogs on how to set up GTM in Weebly and it is very confusing.  GTM has provided 2 snippets of code.  The first to be placed in the header.  I pasted this into the SEO page in the Header box under Settings.  As for the second snippet of code, it says to paste the code immediately after the <body> code.  Should this code go into the box titled Footer?  I have also read posts where it says to place the code inside the html under theme.  

Can you please clear this up in the most basic instructions possible.  

Thank you.

2,752 Views
Message 2 of 21
Report
Square

Hi @Condoleeza Sounds like you are on the right track. Smiley Happy Try using the Embed Element in the builder bar to add the second code to the body. Drag/drop onto your page then paste the code in. 

2,751 Views
Message 2 of 21
Report

Hello! I have pasted the first code into the header. But when I past the second code into an "Embed Code" box at the end of my blog which is where I want the Like and Share buttons to appear, there's just a blank space where the buttons should be? Any tips please?

A previous solution read:

For the blog, you'd probably need to customize the HTML of whichever page type the blog page uses (this would also add it to any other page of the site using the same page type).  You can do that by going to the Theme tab, click Edit HTML / CSS, then clicking on the appropriate page template to the left.

- Adam
Community Manager
 
I also tried this, but might you be able to add exactly where to put the code please? I have no idea what I'm doing! Smiley Happy
2,355 Views
Message 2 of 21
Report
Square

Hi @sandiola. It sounds like you are adding the code properly. Can you post a link to the blog page you are referring to? Thanks! 

2,348 Views
Message 2 of 21
Report

2,346 Views
Message 2 of 21
Report
Square

Super sorry for the delay, @sandiola! It's been a bit hectic with the holidays. Your blog looks great and it looks like you figured out the social media buttons? 

2,340 Views
Message 2 of 21
Report

Hi Bernadette ~ 

No! I hadn't realised! That's strange... just a delay of some kind??

2,339 Views
Message 2 of 21
Report
Square

Possibly, but let me know if you are still running into an issue. Happy Holidays!! Heart

1,156 Views
Message 2 of 21
Report