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 | http://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.