1

I am trying to do a server side call to Google Analytics 4 with a valid Measurement ID (G-0GHN4RGNDQ) it's a test one, so OK to share here, see https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#v and the debug call here:

https://www.google-analytics.com/debug/collect?v=1&tid=G-0GHN4RGNDQ&cid=555&t=event&ec=MyCategory&ea=MyAction&el=MyLabel

I get this error

{
  "hitParsingResult": [ {
    "valid": false,
    "parserMessage": [ {
      "messageType": "ERROR",
      "description": "The value provided for parameter 'tid' is invalid. Please see https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters for details.",
      "messageCode": "VALUE_INVALID",
      "parameter": "tid"
    } ],
    "hit": "/debug/collect?v=1\u0026tid=G-0GHN4RGNDQ\u0026cid=555\u0026t=event\u0026ec=MyCategory\u0026ea=MyAction\u0026el=MyLabel"
  } ],
  "parserMessage": [ {
    "messageType": "INFO",
    "description": "Found 1 hit in the request."
  } ]

I can successfully make gtag calls using that same Measurement ID and the events show up in Google Analytics... however I can't seem to get it to work via the /debug/ url above.

Any help appreciated.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
aginsburg
  • 1,223
  • 1
  • 12
  • 22

1 Answers1

3

You appear to be using the endpoint for Measurement Protocol (Universal Analytics)

https://www.google-analytics.com/debug/collect?tid=fake&v=1

However yet you state you are trying to use Google Analytics 4 which implies GA4 and not Universal analytics.

You should be using Measurement Protocol (Google Analytics 4)

POST /mp/collect HTTP/1.1
HOST: www.google-analytics.com
Content-Type: application/json
<payload_data>

For validating hits check this page page

Note:

Remember the measurement protocol is used to send Data TO Google Analytics not request data from google analytics.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • Thanks. That helped - now using the Alpha API as per you link. and the error has gone. I probably will need to post a separate question as, now I validate and get back no (empty array of `validationMessages`) but cannot see the events in GA – aginsburg Nov 21 '21 at 22:32
  • 1
    Ha ha... it was actually working - I needed to look in the "real time" view in GA – aginsburg Nov 21 '21 at 22:56
  • it takes 24 - 48 hour's for processing to complete. As you saw nothing show's in the normal reports until that is complete. Checking real-time you can validate that its at least receiving you requests – Linda Lawton - DaImTo Nov 22 '21 at 08:11