If you're new here, you may want to subscribe to my RSS feed. Or for more frequent updates you can follow me on Twitter. Thanks for visiting!
This is the first of a number of Google Analytics Tutorials, written to provide you with the knowledge to be able to use Google Analytics for your own projects. This tutorial will cover basic setup and implentation of Google Analytics and is aimed at someone new to Google Analytics. However, other tutorials will cover more advanced topics such as: filtering unwanted data, setting up conversion goals, tracking e-commerce sites and more.
Basic Setup
If you have never used Google Analytics or any other of Google’s many services the first thing you will need to do is create a Google Account to be able to use the other services like Google Analytics.
After you have created your Google Account you then need to sign up to Google Analytics. Once this is done you need to add a new website profile for the site you wish to track.
You will then be provided with the tracking code you need to add to your website for Google Analytics to operate correctly. This code should be placed on every page [you wish to track] of your site. For this wordpress powered site I was able to insert the code into the footer template file. Inserting the code into an include or template file is far easier than manually adding it to every page and I would recommend doing it that way if you can. It is also advisable to add the code just before your closing </body> tag.
After you’ve added this code to your website you will have to wait a little while (12-24hrs) as data is gathered about your website. You will, however, be able to see in your analytics overview ‘waiting for data’ by the status if you have installed the tracking code correctly.
Tracking websites that use subdomains
If your website uses subdomains you have to add the following line to the tracking code to be able to track the site correctly: _udn="mydomain.co.uk";. So if we used subdomains on this website our tracking code would look like this:
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript" >
_uacct="UA-xxxxxxx-x";
_udn="adamjctaylor.com";
urchinTracker();
</script>
Tracking third party domains
Perhaps your website has a shopping cart hosted on a third party domain that you would like to track. In this case, you have to modify the tracking tag and change any links that take a user from your domain to the third party domain.
You must include the lines in bold in the tracking code to track third party domains:
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript" >
_uacct="UA-xxxxxxx-x";
_udn="none";
_ulink=1;
urchinTracker();
</script>
Then for any links from your site to the third party domain you must rewrite then to this format:
<script type="text/javascript">
document.write('<a href="javascript:__utmLinker('https://www.securecart.com/?store=parameters');">Purchase Now</a>');
</script>
<noscript>
<a href="https://www.securecart.com/?store=parameters">Purchase Now
</noscript>
If you use forms to take the user from your domain to the third party domain you must use the following code:
<form action="http://newdomain.com/form.cgi" onSubmit="javascript:__utmLinkPost(this)">
Now your Google Analytics service should be providing basic tracking capabilities and reporting about your website. Do leave a comment, or get in contact if you have any questions.
Related Articles:
Don’t forget to subscribe to the Conversion Matters feed!
Related posts:
- Google Analytics Tutorial – Advanced e-commerce tracking
- Google Analytics Tutorial – How to filter unwanted data in Google Analytics
- Google Analytics Tutorial – How to track conversion rates
- Adding Google Analytics tracking to 1shoppingcart
- Was there a reason for the recent Google Analytics downtime?
Bookmarking
-
Stumble | Digg | del.icio.us | RSS



{ 5 comments… read them below or add one }
Great article. I dumped my hosting companies Webstats after finding Google Analytics. But there’s not a whole lot of info on how to configure it the first time. Thanks for your article…got it setup in less than 15mins.
David
No problem David, glad it was helpful.
OMG I can’t believe I was paying my hosting company to provide similar details to me. Thanks a lot for explaining it, I must get analytics going. Will be back to you if I need help.
Thanks!
Great info! I didn’t know that you could add subdomain and third party tracking to analytics. I was creating new user accounts and this should save some time.
Great overview!! At AZ search engine optimization we’ve been using Google Analytics for some time now. We like having the Webstats at our fingertips!!