I need to send Measurement Protocol, but clietID cookie may not exist. ClientID is required parameter. What to do in this case? Generate it? In which way? (I need to do in on PHP)
Asked
Active
Viewed 2,119 times
2 Answers
2
The clientId is used to tie up the session. You can post a dummy clientId as a UUID, but the event will be stored in a new session. Take a look at Client Id section within Measurement Protocol - more information on UUID can be found inside of A Universally Unique IDentifier (UUID) URN Namespace
If you are working with a User (as opposed to standard) View, the UserId can be used to tie multiple sessions together, providing the UserId (UID) matches

Daryl Wenman-Bateson
- 3,870
- 1
- 20
- 37
2
If anyone else have the problem that hits wont get registered, if cid is empty, I just found out that the docs are wrong:
Client ID: Optional. This field is required if User ID (uid) is not specified in the request.
cid is always required, even if uid is set. Otherwise the hit won't get registered.

Franz Wilding
- 23
- 2
-
+1 This can't be stressed enough. It is a shame that even after two years have gone by, the documentation is still wrong. – aefxx Mar 20 '19 at 17:20
-
1The client id is required for a standard view, but optional for a user view. For a user view the user id is required. Regardless, the documentation needs to make that clear! – Mike May 16 '19 at 20:04
-
I'm pushing custom event from the client with userID set and then from the server side I'm using measurement protocol to push custom event for the same userID, I'm not setting any CID, will session unification handle that or? – Markuz Shultz May 10 '20 at 10:02
-
Worth noting the docs say one of either client id or user id is required. If you supply user id the hit is registered, but only in a user id view (assuming you have one I guess) – Matt Evans Aug 04 '20 at 10:26