Google Analytics - How to get the client_id (anony

2019-07-07 00:11发布

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条回答
疯言疯语
2楼-- · 2019-07-07 00:59

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
    });
  }
}
查看更多
登录 后发表回答