Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UserId, CID in measurement protocol

Measurement protocol To Identify a new user vs. returning user , can we use the user id field . ( i.e we can hash username or other identifier unique to the user and associate it with a particular user . This way we can identify new users vs. returning users effectively.

Question on CID -- CID is used to indentify a user's session uniquely till the session expires. Do we have to track the session expiration manually to generate cid per user session ?

Pls clarify

like image 807
user476566 Avatar asked Oct 01 '22 22:10

user476566


1 Answers

A long time after but that could help other people ...

My understanding is that the CID references a device while the UserID references an authenticated user.

So basically, all the hits with the same Client ID or User ID will be associated to the same user in GA (take a look at session unification though).

"A client id represents a unique device/browser. Whereas a user id represents a unique user that may interact with your website using multiple devices/browsers." from Optimizesmart article

A session in GA is represented by a group of hits both :

  • less than 30 minutes away from the previous hit
  • having the same source/medium/campaign
  • having the same CID

You don't need to track the session expiration manually, you can always send the same CID, Google will handle the sessions split. You only need to explicit the session expiration if your own sense of session is different from Google's.

So in your case, I would generate a CID for each device that is connecting to the service and let Google handle the sessions split for that device.

If you add a UserID for cross-device tracking, then Google will consider all the sessions with the same UserID as being a single user.

Example :

  • User A comes on your website on device X (CID = X)
  • User A comes on your website on device X 2 hours later (CID = X)

At that point Google will understand 2 sessions for 1 user.

  • User A logs on your website on device X (CID = X, UID = A)
  • User A comes on your mobile app on device Y (CID = Y)
  • User A logs on your mobile app (CID = Y, UID = A)

With session unification enabled, the UserID A will be propagated to all the session on device Y so Google will understand 3 sessions, (2 devices), 1 user.

Returning users are calculated with that scheme, here User A generated 1 new visit and 2 returning visits.

I'm currently working with that pattern and everything looks just fine but it's a touchy subject and if anyone knows better or has remarks and advices, I would take them !

like image 139
TimmyCarbone Avatar answered Oct 30 '22 12:10

TimmyCarbone