Gerrit Bertier
Gerrit Bertier

Reputation: 4221

Referral lost after redirect

I have a website (www.accent.jobs) which contains a language selection tool on the www. subdomain. When choosing a language, a cookie is set, so the user only sees the language selection page once, and automatically get redirected the right way next time.

What I notice in Analytics, is that traffic from the www to a subdomain (be.accent.jobs for instance) is seen as referral traffic.

What I do on the www. subdomain:

When the user goes back to the www. subdomain, the redirect is done through PHP using a 302, without a page rendering.

Any ideas on how I could get the traffic from www. to a subdomain not to be handled as referral traffic in Analytics? I would like to keep the original referrer (the site that referred to www.accent.jobs) as the referrer in Analytics.

This is the tracking code on both the www and the be. subdomain:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-xx']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setDomainName', 'accent.jobs']);
_gaq.push(['_addIgnoredRef', 'accent.jobs']);
_gaq.push(['_addIgnoredRef', 'be.accent.jobs']);
_gaq.push(['_addIgnoredRef', 'nl.accent.jobs']);
_gaq.push(['_addIgnoredRef', 'ro.accent.jobs']);
_gaq.push(['b._setAccount', 'UA-xxxxxx-x']);
_gaq.push(['b._trackPageview']);
_gaq.push(['b._setDomainName', 'accent.jobs']);
_gaq.push(['b._addIgnoredRef', 'accent.jobs']);
_gaq.push(['b._addIgnoredRef', 'be.accent.jobs']);
_gaq.push(['b._addIgnoredRef', 'nl.accent.jobs']);
_gaq.push(['b._addIgnoredRef', 'ro.accent.jobs']); 
    
(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);
})();

PS: I'm tracking on multiple UA accounts to keep the data in an older account as well, hence the 'double' tracking code.

Tries

Upvotes: 4

Views: 858

Answers (2)

mike
mike

Reputation: 7177

Move the _trackPageview calls after the _setDomainName and _addIgnoredRef calls.

_setDomainName sets the domain for the GA cookies, which get set during _trackPageview. By having _setDomainName after _trackPageview, the default cookie domain is used, resulting in two different sets of cookies, and the data not transferring between domain/subdomain.

Upvotes: 1

greg
greg

Reputation: 2349

Your _setDomainName usage is correct and sufficient. But its value is never send to Analytics : you must use it BEFORE _trackPageview.

Then _addIgnoredRef is not useful anymore.

Upvotes: 1

Related Questions