I have a website ( www.accent.jobs ) that contains a language selection tool at www. subdomain. When choosing a language, a cookie is set, so the user sees the language selection page once and is automatically redirected the next time.
What I noticed in Google Analytics is that traffic from www to a subdomain (for example, be.accent.jobs) is considered referral traffic.
What am I doing on www. subdomain:
- The user clicks on the link.
- Javascript executes an AJAX request to a PHP file that sets a cookie.
- The user is redirected via JavaScript using
window.location .
When the user returns to www. subdomain, redirection is done through PHP using 302 without page rendering.
Any ideas on how I can get traffic from www. to a subdomain that should not be treated as referral traffic in Google Analytics? I would like to keep the original referrer (the site that linked to www.accent.jobs) as a referrer in Google Analytics.
This is the tracking code on both www and 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 am tracking several UA accounts in order to store data in a higher account, hence the βdoubleβ tracking code.
Is trying
- Tried replacing JavaScript redirection with header redirection on server side 302 in PHP, no luck.
- Also tried using only JavaScript redirects, still no luck.
source share