Two different analytics conflict -


i have been looking while before coming ask here, because know topic has been covered. needed put 2 different analytics on same website, inserted code before closing head tag of every page on website. found solution seemed work, creating 2 different trackers , sending them separately. results don't match : first tracker shows 70 visits, whereas second 1 shows 800, , set both @ same moment.

(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-40380819-3', 'auto',{'name': 'tracker1'}); ga('tracker1.send', 'pageview');   (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-64657532-1', 'auto',{'name': 'tracker2'}); ga('tracker2.send', 'pageview'); 

what doing wrong here ? if there better solution opened it.

thanks help.

load library once time!

(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-40380819-3', 'auto',{'name': 'tracker1'}); ga('tracker1.send', 'pageview');   ga('create', 'ua-64657532-1', 'auto',{'name': 'tracker2'}); ga('tracker2.send', 'pageview'); 

explanation

70 visits first tracker there because first async loader faster second 1 , fires pageview before second tracker overwrites first one. 800 visits should correct.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -