Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html" rel="nofollow noreferrer">Google Analytics recommends placing the asynchronous</a> snippet just before the <code>&lt;/head&gt;</code> tag. </p> <pre><code>&lt;script type="text/javascript"&gt; var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); &lt;/script&gt; </code></pre> <p>In the days before the asynchronous syntax, the recommendation was to put it before the closing <code>&lt;/body&gt;</code> tag, to prevent page load blocking. This is no longer a serious concern. </p> <p>The only things this script will do in a blocking way is it will create a simple JavaScript array, insert some basic values, and then execute an anonymous function. The browser will move on and continue to load, while in the background the browser will request <code>ga.js</code> from Google servers, and then execute a <code>__utm.gif</code> request to Google's servers with the tracking information. </p> <p>Because this <a href="https://stackoverflow.com/questions/3754367/explaining-google-analytics-async-tracker/3755571#3755571">script is inserted in a non-blocking, asynchronous way</a>, it doesn't prevent your content from loading on time. Placing it this early will allow you to track a larger percentage of people, including those who click away when only part of the body is loaded. Further, it reduces the possibility for error if you have event-driven tracking within your page.</p> <p>Also, because Google Analytics is nearly always served from one of two URLs (Google's HTTP and HTTPS versions), the file is likely cached on basically any browser your users have, meaning that the script itself won't have to be transferred. </p> <p>Simply put, best results are guaranteed if you put that snippet at the end of your <code>&lt;/head&gt;</code> tag.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload