javascript - GA Cross Domain Tracking - Not Tracking Correctly -


really hope can help. i'm setting cross domain tracking site has it's checkout process on separate domain.

i set brand new universal analytics account track both sites, , had implemented wrong (classic analytics) cross domain code on site 1...

<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setaccount', 'ua-xxxxxxxx-1']); _gaq.push(['_setdomainname', 'site1.co.uk']); _gaq.push(['_setallowlinker', true]); _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>   

however tracking correctly in new ua account. noticed had old version on code on there changed to..

<script> (function(i,s,o,g,r,a,m){i['googleanalyticsobject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q|| []).push(arguments)},i[r].l=1*new date();a=s.createelement(o), m=s.getelementsbytagname(o) [0];a.async=1;a.src=g;m.parentnode.insertbefore(a,m) })(window,document,'script','//www.google- analytics.com/analytics.js','ga');  ga('create', 'ua-xxxxxxxx-1', ‘site1.co.uk' ‘auto’, {   ‘allowlinker’: true }); ga('require', 'linker'); ga('linker:autolink', ['site2.co.uk'] ); ga('send', 'pageview'); </script> 

but tracking has messed , it's gone tracking thousands of visits day under 100. there wrong new code put on here? seems weird tracking fine old ga code , not new.

i haven't put code on site 2 yet, want right first. appreciate here, , bear in mind i'm no coder :)

thanks much, david

your problem here.

ga('create', 'ua-xxxxxxxx-1', ‘site1.co.uk' ‘auto’, { ‘allowlinker’: true    }); 

from the reference ( https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference#create ):

ga('create', trackingid, opt_configobject); 

you can't drop domain create statement tracker. if could, missed comma , used backticks rather single quotes. moreover, domainname no longer exposed option used be. if want 1 code track 2 domains best bet put domain in custom variable, userdefined value or custom dimension.

ga('set', 'dimension1', 'site1.co.uk'); 

edit:

looking through documentation there hostname field can set:

ga('set', 'hostname', 'site1.co.uk'); 

moreover, , didn't think ask before, did upgrade ua account google analytics universal right? https://support.google.com/analytics/answer/3450662?hl=en


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -