Google Analytics missing __utmz cookie

后端 未结 4 1511
天涯浪人
天涯浪人 2021-01-02 10:54

I have universal analytics installed on my website, and want to parse the __utmz cookie to get referral info. However, I never see this cookie set.

Has

相关标签:
4条回答
  • 2021-01-02 10:57

    Universal Analytics doesn't create any __utm* cookies.

    However, you can use Universal Analytics code (analytics.js) AND the traditional code (ga.js) simultaneously on your site. This will allow you to populate your UA profile and scrape the values from __utmz.

    0 讨论(0)
  • 2021-01-02 10:59

    Use below code to get utmz cookie along with your universal analytics js code

    <script type="text/javascript">
    
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-XXXXX-X']);
    
      (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>
    
    0 讨论(0)
  • 2021-01-02 11:10

    You can create your own cookie and store the query string parameters that google analytics use (utm_campaign and etc). See this project as example: https://github.com/dm-guy/utm-alternative

    0 讨论(0)
  • 2021-01-02 11:16

    It seems like with Universal Analytics, this cookie has disappeared, and you only get a single _ga cookie.

    Source: https://developers.google.com/analytics/devguides/collection/analyticsjs/cookie-usage

    Also mentioned here: How to get the referrer, paid/natural and keywords for the current visitor in PHP with new Google Analytics?

    Also given that analytics is primarily a tool to collect aggregated information, I couldn't find (and I doubt) that there is any way to query GA to get this info back, given the _ga cookie.

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