2

We currently have Analytics tracking codes running throughout our site including our Sub Domains.

What I would like to do is create different Profiles under the same account segmenting the sub domains by means of filters.

Currently I am just excluding the hostname of the main website by using the following custom filter:

Exclude: Hostname Filter pattern: ^www.mydomain.co.za(.*)

I know this isn't the proper method of doing this though and have some of the main domains links coming through in the data.

Ideally I would just like to include anything from: sub.domain.co.za

Any help would be greatly appreciated.

migrated from superuser.com Jan 24 '11 at 12:59

This question came from our site for computer enthusiasts and power users.

  • Could you clarify? Do you want to be able to do a report of all data and one report per sub domain? – Ben Hoffman Jan 24 '11 at 13:31
1

Try this: http://code.google.com/apis/analytics/docs/tracking/gaTrackingSite.html#multipleDomains

Where you would modify

_gaq.push(['_setDomainName', '.example-petstore.com']);

to

_gaq.push(['_setDomainName', '.mydomain.co.za']);

The profile for each subsite could us a custom filter on hostname to show only traffic to the subsite.

1

Using _setDomainName overwrites the hostname - which means that you can no longer distinguish which subdomain the visit came to.

More specifically sub.mydomain.co.za/index.html and www.mydomain.co.za/index.html would both be tracked as a visit to www.mydomain.co.za/index.html

Perhaps I mis-understand the question, but it sound like what you are wanting is straight-forward - a separate profile filtering traffic for each sub-domain.

Try this:

Custom Filter Include: Hostname Filter pattern: sub\.domain\.co\.za

  • "_setDomainName overwrites the hostname" where is this documented? I've seen solutions to this problem similar to the other answer, which also use a hostname filter, but that would not work if this statement is correct. – roryf Oct 19 '12 at 10:38
0

I don't know if this was true in 2011 when this question was asked but as of 2017 (and for at least a few years before) it was not ideal to use filters in GA for the situation described.

The reason for that is that Google Analytics uses data sampling when generating reports and that sampling occurs before filters are applied.

Here's a concise explanation of tracking users across sub-domains.

You also probably want to add the hostname to your reports (otherwise it's difficult to separate traffic to the home page / of all of the domains) so have a look at this tutorial.

Additionally, it's not unheard of that your GA tracking code ends up sending hits from another domain...might be a dev or staging site, might be someone copied your content, might be spammers.

So it's useful to be able to see that and restrictive filters like described would probably complicate that...no matter what you should always have one unfiltered view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy