Google Analytics - Multiple Trackers for Several A

2020-05-20 07:18发布

Maybe I'm going about this wrong, but I'm hoping I can get some insight. I develop for multiple clients nationwide. I track many of my sites using my personal/development Analytics account that tracks all the domains/profiles I work on. However, I now have marketing folks jumping into the fray, all wanting their own GA trackers installed (and some other 3rd party trackers but that's irrelevant... I think?) that are associated to their own accounts.

So, I've seen some discussion regarding entering multiple trackers into the code (and the possibility of corrupt cookies and data). Simply, is there a better way I could be going about this? I'd prefer to keep them out of my account, this way if any relationships go sour historical data can be preserved.

Am I missing something?

Thanks!

5条回答
祖国的老花朵
2楼-- · 2020-05-20 07:25

From the asynchronous api documentation

Pushing commands to multiple trackers also works.

_gaq.push( ['_setAccount', 'UA-XXXXX-1'],
           ['_trackPageview'],
           ['b._setAccount', 'UA-XXXXX-2'],
           ['b._trackPageview']);
查看更多
聊天终结者
3楼-- · 2020-05-20 07:27

This also works for calling multiple _trackPageview after the page is loaded (for additional recorded actions, for example, tracking when somebody downloads a PDF)

<script type="text/javascript">
    var ua_codes = ['UA-XXXXX-1', 'UA-XXXXX-2', 'UA-XXXXX-3']
    var _gaq = _gaq || [];
    for(i in ua_codes) {
        _gaq.push(['_setAccount', ua_codes[i]]);
        _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>

<a href="/some_document.pdf" onClick="record_click(this.href);">Read the pdf</a>

<script type="text/javascript">
    function record_click(track_url) {
        for(i in ua_codes) {
            _gaq.push(['_setAccount', ua_codes[i]]);
            _gaq.push(['_trackPageview', track_url]);
        }
    }
</script>
查看更多
Ridiculous、
4楼-- · 2020-05-20 07:30

I think its common thing. Samething happens in the company I work for. We have GA and loads of other tags from marketing guys. We just have to live with it.

Analytics is best used by Marketing guys.

查看更多
我命由我不由天
5楼-- · 2020-05-20 07:43

It's possible to have multiple trackers on one site, for example like this:

<script type="text/javascript">
var trackerA = _gat._getTracker("UA-XXXXXXX-X");
trackerA._initData();
trackerA._trackPageview();
var trackerB = _gat._getTracker("UA-XXXXXXX-X");
trackerB._initData();
trackerB._trackPageview();
</script>

Another option is to link multiple Google accounts to a single Google Analytics account (using the User Manager -link in the GA account overview).

查看更多
够拽才男人
6楼-- · 2020-05-20 07:46
登录 后发表回答