: Tracking source/medium across domain to subdomain My website is hosted on a domain such as example.com, and website visitors progress from example.com to sub.example.com where we host surveys. At
My website is hosted on a domain such as example.com, and website visitors progress from example.com to sub.example.com where we host surveys. At the moment, visitor data lists example.com as the main traffic source to sub.example.com. I want the source/medium and other data to be preserved when visitors go from example.com to sub.example.com, so I can look at certain pages on sub.example.com and see how they originally got to example.com.
Here is the analytics code for example.com:
<script type="text/javascript">//<![CDATA[
// Google Analytics for WordPress by Yoast v4.3.5 | yoast.com/wordpress/google-analytics/ var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2596968-5']);
_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);
})();
//]]></script>
And for the sub.example.com:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2596968-5']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview', '/surveys/[survey name]/[location]/page[number]-[status].html']);
} catch(err) {}</script>
Note: The fields in square brackets are automatically inserted from the survey software.
More posts by @Mendez628
1 Comments
Sorted by latest first Latest Oldest Best
You need to set the same domain name on each subdomain. On your code change only second parameter for yours domain name in that part:
_gaq.push(['_setDomainName', 'none']);
More info: developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite?hl=pl#domainSubDomains
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.