javascript - Google Analytics Link Account Not working -


i have been trying track more 3 sites of mine using single google analytics code. in case have tried track using following code got blog.

  (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');    //load plugin.   ga('require', 'linker');    // define domains autolink.   ga('linker:autolink', ['www.abc.com', 'www.def.com']);   ga('create', 'ua-xxx8xxx4-1', 'auto', {       'allowlinker': true,       'cookiedomain': 'none'     });    ga('send', 'pageview'); 

where www.abc.com site have created property in google analytic's account name of "abcpropery" , tracking id against account got ua-xxx8xxx4-1.

now problem track page views on www.abc.com not on www.def.com.

so, want track page views of abc.com , def.com. while have added above script in master pages of both sites (i.e. www.abc.com, www.def.com).

can 1 me on how can track both site using single code? , doing wrong here?

just use following:

(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');  //load plugin. ga('require', 'linker');  // define domains autolink. ga('linker:autolink', ['www.abc.com', 'www.def.com']); ga('create', 'ua-xxx8xxx4-1', 'auto', {     'allowlinker': true });  ga('send', 'pageview'); 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -