Browsing articles tagged with " firebug"
Apr 5, 2009

How To Track Sub-Domains / Cross-Domains in Google Analytics

First of all, let me explain why in Google Analytics you need to do some configurations to track sub-domains / cross-domains.

Google Analytics does not do this by default, thus whenever you’re on and you go to, Google Analytics will record this as a referral rather than maintaining the same session and the same campaign information. If you’re running e-commerce tracking and you use sub-domains during the e-commerce process, this will totally screw up your reports as it will attribute all transactions to referrals (from your own site) and you will have no idea how your other online marketing campaigns (i.e. direct, organic, cpc) are performing.

Sub-Domain Tracking

This one is fairly easy. The method you need to use is _setDomainName().

Google utma cookie

The _setDomainName() method sets the Google cookies to the domain name string parameter that it is given, otherwise it automatically resolves the domain name from the location object in the DOM if no parameter is given. This means that on sub-domains, the cookies will be set to separate sub-domains.

So to configure Google Analytics to set the cookies to the same domain name, simply use the domain name as the string parameter for the _setDomainName() method.

E.g. If I have a website called and, I would use _setDomainName(‘’) throughout all my pages (sub-domains and main domain).

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "' type='text/javascript'%3E%3C/script%3E"));

<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxx-x"); // replace this with your own account number

The Google API officially states to use the period at the start of the domain name. I have tried with and without and it seems to work fine but I prefer without period (looks nicer).

Once you’ve done this, Google Analytics should record all visits to these sub-domains as the same visit, maintaining the same campaign information. However, in your reports,you won’t be able to tell which request URI came from which sub-domain as the domain name is stripped out from the reports.

In addition, if you have two sub-domains that have the same page name (i.e. index.html), then Google Analytics will combine these two into one which will artificially inflate your page statistics.

A simple way around this is to implement what I call a sub-domain visibility filter which will prefix your request URI’s with the domain name. This will help you differentiate the pages as well as avoid inflating the page statistics.

Continue reading »

Mar 15, 2009

Google Analytics: Does 301/302 Redirect Preserve Referrer Information?

In case you’re wondering whether 301 redirects preserve the referrer information or not and how this may affect Google Analytic’s referrer information, I’ll show you a simple example.

So pretty much what I did was I did a Google search for clothes and found some ads on the right hand side. I used firebug to extract the destination URL as I didn’t want to inflate their costs because I’m just doing an example. What I look for are obvious tracking URLs that track and monitor search engine marketing (SEM) campaigns such as DART (Double Click).

You can also figure this one out by seeing the domain of the URL. If this is different to the display URL, most likely this is a tracking URL because Google Adwords has enforced the policy that the destination and display URL must be the same (it’s ok to use tracking URLs though as long as you land on the same domain as the display URL).


Continue reading »

Twitter Updates