Adding the tracking code (traditional)
Note: This article is for the traditional version of the tracking code. We recommend you update your tracking code to use the latest (asynchronous) version. For instructions on using the latest version, see this
article.
Please follow the instructions below to add the tracking code to your site.
- Finding your personalized Google Analytics Tracking Code
The tracking code is profile-specific, which is why you can only access it via the Profile Settings page for a specific profile. Please read Where can I find my tracking code? for full instructions. Below is an example of what the code snippet will look like. You'll need to update the "xxxx-x" in the sample below with your own Google Analytics account number found in your personalized Google Analytics Tracking Code.
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._trackPageview();
} catch(err) {}
</script>
- Implementing the code
Once you find the code snippet, copy and paste it into the bottom of your content, immediately before the </body> tag of each page you are planning to track. If you use a common include or template, you can enter it there. To implement tracking code for secure pages (e.g. https://), please read How do I obtain tracking code for secure pages?
- Implementing the code for unique pages
For more information on how to implement the tracking code for data-driven pages or pages with frames, please follow the instructions from the relevant section in the Google Analytics Installation Guide.
- Troubleshooting
You should be finished once you install and save your tracking code for your pages. If you wait 24 hours and still don't see any data, please read Why isn't Google Analytics tracking my Website?
If you don't know how to insert the code into the pages of your site, please contact your webmaster and ask him or her to follow the steps above.