How to install Asynchronous Tracking in Google Analytics
First Time Installation of Asynchronous Tracking:
Following are steps if you are installing Google Analytics Code on your site for first time and you want to use Asynchronous Tracking.
- Insert the asynchronous snippet at the bottom of the <head> section of your pages, after any other scripts your page or template might use.
- According to Google the optimal location for the asynchronous snippet is at the bottom of the <head> section, just before the closing </head> tag.
- Modify the _setAccount method with your web property ID. (check screen shot below)
And you are done! - You can get the Asynchronous Tracking code from this post or from Google here.
Migrating or Upgrading to New Asynchronous Tracking:
If you want to migrate/upgrade to the new asynchronous snippet from traditional tracking :
- Remove your existing tracking code snippet and any customizations you have made.
- To reduce errors, it is recommended that you remove the existing tracking code snippet from the include file or mechanism that injects it into your web pages. [TIP] You can paste your existing tracking code snippet in a text file to keep track of any customized methods you use.
- Use the steps defined above to install new tracking code.
To make customizations to your new Asynchronous Tracking code like you have done to your old code, check out this usage guide and side by side comparison from Google.
