Analytics
2.3K members online now
2.3K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Where Does Tracking Code Belong on My Index Page

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

<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', 'UA-65956969-1', 'auto');
ga('send', 'pageview');

</script>

 

Can I put the tracking code before or after the slideshow code on the index page?

www.writtencommunicationcompany.com

1 Expert replyverified_user

Re: Where Does Tracking Code Belong on My Index Page

Explorer ✭ ✭ ☆
# 2
Explorer ✭ ✭ ☆
Hey Curtis,

The answer is as soon as possible after the <body> tag - ideally immediately after.

If you can only insert it before or after your slideshow code, load it in before.

I hope this helps!

Ali

Re: Where Does Tracking Code Belong on My Index Page

Top Contributor
# 3
Top Contributor
Hi Curtis,

place your tracking code at some point into the HTML-HEAD section of your pages [1].

Placing it into the HTML-BODY section is rather a recommendation for Google Tag Manager code, not for Google Analytics code.

Christoph

[1] https://support.google.com/analytics/answer/1008080?hl=en

Re: Where Does Tracking Code Belong on My Index Page

Explorer ✭ ✭ ☆
# 4
Explorer ✭ ✭ ☆

Sorry @Curtis D yes @webfield is right - before the closing </head>.

 

I was thinking about GTM.

 

If your website is built with a CMS, it should be quite easy to find the file that loads the <head> content, or even a plugin that'll do it for you.

 

If it's static HTML you would need to include it in every page.

 

Ali