Mobile app version of vmapp.org
Login or Join
Mendez628

: 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

@Mendez628

Posted in: #Analytics #GoogleAnalytics

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.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Mendez628

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ravi8258870

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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme