Mobile app version of vmapp.org
Login or Join
Kaufman445

: Setting up Google Analytics for multiple subdomains so first here's a snippet of my current Analytics javascript: var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-30490730-1']); _gaq.push(['_setDomainName',

@Kaufman445

Posted in: #GoogleAnalytics

so first here's a snippet of my current Analytics javascript:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-30490730-1']);
_gaq.push(['_setDomainName', '.apartmentjunkie.com']);
_gaq.push(['_setSiteSpeedSampleRate', 100]);
_gaq.push(['_trackPageview']);
(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);
})();


So if you wanna have a quick peak at the site the url is ApartmentJunkie.com, keep in mind the site is pretty bare bones but you'll get the idea -- basically it's very similar to craigslist in the sense that it's in the local space so people pick a city then get sent to a subdomain that is specific for that city, e.g. winnipeg.mb.apartmentjunkie.com.

I put that up late last night then had a look at the analytics and found that I am seeing only the request uri portion of the URLs in analytics as I would with any other site only with this one it's a problem as winnipeg.mb.apartmentjunkie.com/map/ and brandon.mb.apartmentjunkie.com/map/ are two different pages and shouldn't be lumped together as /map/

I know the kneejerk response is likely going to be "hey just setup a different google analytics profile for each subdomain" but there will eventually be a lot of subdomains so google's cap of 50 is going to be too limited and even more important I want to see the data in aggregate for the most part.

I am thinking of making a change to the javascript, to something like:

_gaq.push(['_trackPageview',String(document.domain) + String(document.location)]);


But am unsure if this is the best way and figured someone else on wm.se would have had a similar situation that they could talk a bit about.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Kaufman445

2 Comments

Sorted by latest first Latest Oldest Best

 

@Speyer207

A filter is probably the best way to go, but make sure you have one profile that has NO filters.

Another handy tool are the Advanced Segments. If all the traffic goes to a single profile, you can create an advanced segment to see just one (or a set) of hostnames. Just set the hostname parameter to match the specific subdomain you want to see.

What is nice about this is that it makes it really easy to compare subdomainA vs subdomainB by creating separate advanced segments for both.

10% popularity Vote Up Vote Down


 

@Nimeshi995

The official documentation recommends using a filter to display the domain name in reports:


In the Profile Settings page, click the Add Filter link.
Choose Add New Filter and provide the filter a name.
Choose Custom Filter and select Advanced on the Filter type settings.
Under Advanced settings:
FieldA should be set to Hostname
FieldB should be set to Request URI
Set the values for both Field A and Field B to (.*), which is an expression that captures all characters.
Set the Output To --> Constructor option to Request URI and provide $A1$B1 as the value for that choice.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme