I'm trying to track traffic for my sub-domain, but it's not happening.
This is how it's set up.

My partner has a domain called sub1.partner.com. This domain points to partner1.mydomain.com. The idea is that users think they are browsing my partners website, when they are in fact browsing pages on my server.

My tracking code looks like this:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
_gaq.push(['_setDomainName', '.mysite.com']);

(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);

In Google analytics I've created a new account under my main account and called in partner1.mysite.com.

On this account I have created a filter:

Filter type: include
Filter field: Host name
Filter pattern: partner1.mysite.no
Case sensetive: No

What more can I try to track traffic on my subdomain?


Question 1
Is this line correct?

_gaq.push(['_setDomainName', '.mysite.com']);

Question 2
Is it correct that I have to add \ before any punctuations like so \. in filters?

  • Have you tried removing the filter? I don't see why you would have a problem if you copied and pasted the code directly from the new analytics profile into your sub-domain html files.
    – Anagio
    Commented Mar 12, 2012 at 13:46
  • From what I have read in various guides, the correct way is not to add another js script to the footer for the subdomain, but rather create a new profile and add a filter for this.
    – Steven
    Commented Mar 12, 2012 at 15:11

1 Answer 1


Here are some resources on how to track a sub-domain in GA





  • Iv'e already been to most of these links. But I still get no result. Need some concrete suggestions on what to try.
    – Steven
    Commented Mar 13, 2012 at 9:34
  • In that case I would contact Google Analytics they can review your tracking code and configuration for you. If you have an adwords account login go through the contact form for Analytics within adwords. Also try posting in the analytics group in Google you may find some certified companies who know the code inside and out.
    – Anagio
    Commented Mar 13, 2012 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.