Dumb SEO Questions

(Entry was posted by Greg Krista on this post in the Dumb SEO Questions community on Facebook, 03/01/2016).

Where to put your GA code?

Does putting your GA code at the end of the  improve a site`s load efficiency? Yes, I know that there are other factors when it comes to this, but I was just curious. I put my GA code, Bing, and Google Webmaster Tools code right before the body tag.
Thanks!
This question begins at 00:07:54 into the clip. Did this video clip play correctly? Watch this question on YouTube commencing at 00:07:54
Video would not load
I see YouTube error message
I see static
Video clip did not start at this question

YOUR ANSWERS

Selected answers from the Dumb SEO Questions Facebook & G+ community.

  • Greg Kristan: Does putting your GA code at the end of the </head> ;improve a site's load efficiency? Yes, I know that there are other factors when it comes to this, but I was just curious. I put my GA code, Bing, and Google Webmaster Tools code right before the body tag.
    Thanks!
  • Federico Sasso: Not much: the default async code creates an async script node, so it doesn't block rendering except for the limited time it takes to create the node.
    Of course you can try, I don't think it would hurt. I suspect they pushed for the current solution to maximize the chance the code is executed, as if the loading is slow and user navigates away it might not be ran.
  • Greg Kristan: +Federico Sasso ;perfect!
     ;Thanks for the help with this question
  • Rotimi Orimoloye (Orims): Right before the body tag?
    Why???
    If I am reading this correctly, you have your javascript code lurking in between the tags? Is this is just experimentation? Or you have actually seen better results for this?

    Putting it within the head is indeed so GA servers can capture hits before users navigate away. And I would argue that even you need that "bounce-rate" data as well. :)

    However, the current solution is actually to use GTM, which tag is placed immediately after the opening <body> tag.
    Why they do this is because we now use the <head> for exposing stuff in the #dataLayer. I mention GTM since you are using Bing, and possibly other 3rd party tracking code in future. ;

    Ofcourse if this is confusing to some folks it is still safer to place your GA tags within the <head> x </head> NOT </head> x <body>
  • Greg Kristan: +Rotimi Orimoloye sorry, I meant the text to say does it make a difference where you put the code in the head tag for page speed. The before the body tag just meant at the end of the <head> tag
  • Rotimi Orimoloye (Orims): +Greg Kristan
    Oh! I see.

    And as for Page Speed, just in case....

    I'm sure you realize this already, but for anyone else reading, I should point out that when considering positioning GA tags.
    "Page Speed" here is not so much about how fast the page renders for a visitor, but more about how fast Google Analytics picks up the JavaScript for collecting data. ;

    It is also worth a mention that anyone that may be experiencing slow page load times supposedly because of GA should stop using old versions of the tag. :)

View original question in the Dumb SEO Questions community on Facebook, 03/01/2016).