Two analytics on one page

前端 未结 1 1441
南旧
南旧 2021-01-24 22:12

How can i put two GA codes on a site. I have this code:

(function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]         


        
1条回答
  •  隐瞒了意图╮
    2021-01-24 22:59

    Your second tracker is overriding the first. It's not per se a problem to have multiple trackers per website, but you need multiple pageview (or other interaction) calls as well. Best way to do this is to use named trackers:

    ga('create', 'UA-XXXX-Y', 'auto', 'tracker1');
    ga('tracker1.send', 'pageview');
    ga('create', 'UA-XXXX-Y', 'auto', 'tracker2');
    ga('tracker2.send', 'pageview');
    

    That way you can make interactions calls to specific trackers by prefixing the tracker name to the send method call.

    0 讨论(0)
提交回复
热议问题