Google Analytics - How to get the client_id (anonymous client id) sent with Measurement Protocol

天涯浪子 提交于 2019-12-23 20:50:16

问题


we are seding requests like this throught the google analytics measurement protocol to track user interaction there. For us its important to be to link a interaction to a specific user so we where happy to be able to set the "cid" attribute of the protocol.

my problem is that I cannot find this Client ID somewhere inside the reports of google analytics. Even when customizing the reports I cannot find a Dimension which allows me to display this information.

http://www.google-analytics.com/collect?
 v=1             // Version.
 &tid=UA-XXXX-Y  // Tracking ID / Property ID.
 &cid=555        // Anonymous Client ID.

 &t=event        // Event hit type
 &ec=video       // Event Category. Required.
 &ea=play        // Event Action. Required.
 &cm18=8000
 &cd6=crocodile

Do you have an idea of how the cid could be found there?


回答1:


Client id is assigned to a user(client) viewing your site by google analytics. Here is an example of how you can get the client id if you're using jQuery.

$(document).ready(function() {
  setGaClientId();
});

var setGaClientId = function(){
  if(typeof(ga) != 'undefined'){
    ga(function(tracker) {
      console.log(tracker.get('clientId')); //actually do something here
    });
  }
}


来源:https://stackoverflow.com/questions/26461439/google-analytics-how-to-get-the-client-id-anonymous-client-id-sent-with-meas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!