Search code examples
google-analyticsgoogle-analytics-firebasemeasurement-protocol

How to specify timestamps per event with measurement protocol


I'm using Measurement Protocol (for Google Analytics 4) and I'd like to send multiple events in batches to send fewer overall requests, but I'm not sure how to specify the timestamp of each individual event.

I'm sending an http post request to the measurement protocol endpoint. The documentation states that the post body has a timestamp_micros field, which is used for all events in the request, unless an event overrides it: "This value can be overridden via user_property or event timestamps".

I could not find a reference for the structure of an event item though, so I'm not sure how to override it. A key name of timestamp would make sense, but the post body itself uses timestamp_micros so maybe events follow that pattern? Or do events even use microseconds?

It's not easy to test because the raw metadata like timestamps aren't available in GA.


Solution

  • Specify the timestamp_micros field on each event to override the value of timestamp_micros on the batch request body.