What Can the GA4 Measurement Protocol Do?
The GA4 Measurement Protocol sends events directly to Google Analytics through HTTP requests, usually from a server or an offline system.
It can record interactions that a browser tag does not send, including purchases and refunds. Google designs it to supplement tagging, so a server event still needs the right identifiers and context to connect to the visitor's earlier activity.
- request
- client_idmeasurement_idapi_secret
- Session context
- session_idengagement_time_msec
- backdated
- up to 72 hours
Daniil Maximkin Published Reviewed
- In practice
What can it add, and what can it not recover?
I use the protocol when the backend knows an event happened and can supply the data GA4 needs. It can connect online and offline behaviour and record server interactions alongside browser events.
It does not recreate a browsing history that was never collected. Google says it supplements automatic collection through the Google tag, Tag Manager or Firebase. An event with no connection to the original visitor is not evidence that the original session’s attribution has been restored.
Events can be backdated by up to 72 hours. That is not a way to backfill last month’s missing purchases, and the backdating limit alone does not guarantee session attribution.
- In practice
What are client_id and transaction_id for?
For a web stream,
client_ididentifies the user instance and should match the ID generated by the website’s GA4 tag. I carry that value into the backend when permitted, rather than replacing it with an order number or a fresh random value for each purchase. The request also needs the stream’smeasurement_idand anapi_secretthat stays on the server.transaction_ididentifies the order on a purchase event. Google documents purchase deduplication for web streams, for transactions from the same user with the same transaction ID. I preserve the browser’s client identity and the same order reference in any server copy. A transaction ID alone is not a promise of deduplication across different users or app streams. - In practice
When does a server event break?
I look for the wrong stream, a lost
client_id, a reused or emptytransaction_id, malformed ecommerce parameters, or an event sent with the wrong time. Session context also matters: Google recommendssession_idandengagement_time_msecfor accurate session and engagement metrics, including Realtime. I use the actual context rather than inventing engagement. - Not to be confused with
Not to be confused with Is not Is evidence that the original session's attribution has been restored supplements automatic collection a way to backfill last month's missing purchases Events can be backdated by up to 72 hours The collection endpoint returns HTTP
2xxwhen it receives the request, even if the payload is incorrect or the event is not processed. Transport success, valid event structure and a correctly reported purchase are three different checks. - Where to check
How do I check a Measurement Protocol event?
- Inspect the prepared payload in a test environment. Compare its client identity and order reference with the browser event and backend record; keep the API secret out of logs.
- Validate a test payload with
/debug/mp/collectandENFORCE_RECOMMENDATIONS. ReviewvalidationMessages; validation events do not appear in reports. - Check the configured stream and secret separately. Structural validation alone does not establish that the credentials are correct.
- In a permitted test property, verify the collected event and its parameters, then reconcile the purchase against the backend order. Do not use the HTTP status as the acceptance check.
- Sources
Sources
Checked on
- Google Analytics: Measurement Protocol overview and capabilitiesdevelopers.google.com
- Google Analytics: sending events, web client identity and secret handlingdevelopers.google.com
- Google Analytics: protocol reference, responses, timestamps and session parametersdevelopers.google.com
- Google Analytics: event validationdevelopers.google.com
- Google Analytics: transaction IDs and web-stream deduplicationsupport.google.com
- Google Analytics: purchase and refund event parametersdevelopers.google.com