Mobile app version of vmapp.org
Login or Join
Murray432

: Is there any benefit of Google Analytics asynchronous tracking code if it isn't placed in the ? I'd like to go to the asynchronous Google Analytics script, but I'd rather not have it in the

@Murray432

Posted in: #GoogleAnalytics

I'd like to go to the asynchronous Google Analytics script, but I'd rather not have it in the head (even though I know this is best practice).

So, is there any benefit of using the async code if it isn't in the head, and alternatively, would it be safe to place elsewhere high in the page, like just inside the opening body tag, or in a .NET user control that loads at the top of the page?

EDIT:

In the instructions Google states:

If that isn't an option, you can still put the asynchronous snippet at the bottom of the page. You can also split your snippet to retain some of the benefits of asynchronous tracking.


If I place the code there (without splitting) do I still benefit from asynchronous loading or is it negligible since it is at the bottom anyway?

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Murray432

3 Comments

Sorted by latest first Latest Oldest Best

 

@Alves908

You can add your analytics code anywhere on your page. Google is smart enough to identify / register all events on your page. When you are talking about async there is no point thinking about its in-line/sync placement.

I have used it at bottom for most of my sites and have found no issues.

The main load events that you get in your google analytics account:

1) Dom load time
2) Page load time

This takes into consideration everything and are independent of where you add your code.It might be possible(with sync code) that these time are calculated on basis of Google script position on page as in :
DOM load time - > time of firing dom load event of browser - GA script loading/event
Page load time - > time of firing window load event of browser - GA script loading/event

If this is the case then script position would play a small role in changing above time to more accurate once else i don't think it make much difference.(as placing it on top brings the page with GA prior to placing it at bottom because page loads sequentially)

10% popularity Vote Up Vote Down


 

@Shakeerah822

Compared to having the old tracking code at the bottom of the page, having the asynchronous code at the top of the <body> should still mean that the tracking is more likely to register users who leave the page (or interact with elements on the page that are being tracked) before it has fully loaded.

10% popularity Vote Up Vote Down


 

@RJPawlick198

You can put it anywhere you just get the most benefit from putting it in the header. The full instruction to add it to your web page are here - code.google.com/apis/analytics/docs/tracking/asyncTracking.html.
You do want to put it inside of the head or body tags though. Just to be clear. But beyond that you can do whatever you want.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme