1

The Google Measurement Protocol documentation claims that the cid is optional if uid is used:

This field is required if User ID (uid) is not specified in the request

So I make the following requests to measurement protocol:

GET https://www.google-analytics.com/collect?v=1&tid=<MY_TID>&aip=1&uid=<USER_ID>&ec=Foo&ea=Bar&el=Baz

But they do not get recorded in Google Analytics.

I make other requests where I specify both uid and cid and they work perfectly. Is there something I am missing? Elsewhere I have read that cid is actually mandatory.

EDIT: SOLUTION

This Answer is a correct answer to my question, so accepted. But I wanted to add that in addition to the fact that these hits were never going to show up in the Main View (only the User ID view), I had neglected to set t=event in my request (necessary for ec, ea and el). The debug endpoint didn't help diagnosing this I just stared at it (and the docs) for long enough to see it.

jsj
  • 9,019
  • 17
  • 58
  • 103
  • Did you check the debug endpoint? https://developers.google.com/analytics/devguides/collection/protocol/v1/validating-hits Did you check the real time reports? is your hit shown there? – Linda Lawton - DaImTo Jun 15 '20 at 11:34
  • @DaImTo I did check the debug endpoint, but unfortuntely it didn't help me with my root problem (I will edit question with my solution). It was not showing up in the realtime report. – jsj Jun 16 '20 at 10:06
  • the debug endpoint should have told you that the call was invalid. – Linda Lawton - DaImTo Jun 16 '20 at 10:34
  • @DalmTo yeah, it should have :/ Unfortunately it didn't say something useful like "ec only valid with event type 'event'", the debug endpoint said it was valid. – jsj Jun 16 '20 at 10:38

1 Answers1

2

It is mandatory because if you don't send it but you send only uid, the hit will be appear only in USER-ID view.

Michele Pisani
  • 13,567
  • 3
  • 25
  • 42