GA4 Measurement Protocol Builder
Build and validate GA4 Measurement Protocol payloads — useful for server-side events, offline imports, and CRM-to-GA4 pipelines.
The GA4 cookie value (_ga). For server-side, generate or look up.
Use dot/bracket notation for nesting: items[0].item_id.
Payload (POST body)
{
"client_id": "1234567890.1620000000",
"events": [
{
"name": "page_view",
"params": {
"page_location": "https://example.com",
"page_title": "Home"
}
}
]
}cURL command
curl -X POST "https://www.google-analytics.com/mp/collect?measurement_id=G-XXXXXXXXXX&api_secret=YOUR_API_SECRET" \
-H "Content-Type: application/json" \
--data '{"client_id":"1234567890.1620000000","events":[{"name":"page_view","params":{"page_location":"https://example.com","page_title":"Home"}}]}'Validation tip: Append ?validation to the URL hostname (/debug/mp/collect) to test before sending real events.
Try these next
Related tools you'll probably want
Need backend events in GA4?
I connect your backend, CRM or checkout to GA4 with the Measurement Protocol or server-side GTM, with clean IDs so nothing is double counted.
How to use the GA4 Measurement Protocol Builder
The GA4 Measurement Protocol lets your server send events straight to GA4, for example a purchase confirmed by your backend or a lead qualified in your CRM. This builder creates a correctly structured request so you can test it before writing code.
Step by step
- Enter your Measurement ID (G-XXXX) and choose the event, such as purchase or generate_lead.
- Add the client_id from the visitor's _ga cookie so the event joins their existing session and attribution.
- Fill in the event parameters (transaction_id, value, currency, items) and copy the generated payload.
- Send it to the validation endpoint first, then send a real test event and check it in GA4 DebugView.
How to read your result
Validation passes and event shows in DebugView
The payload and credentials work. Move the request to your server code.
Validation passes but nothing in GA4
The validation endpoint does not check your API secret. Check the secret, the Measurement ID and add debug_mode while testing.
Event arrives without attribution
The client_id is missing or made up, so GA4 can't join the event to the visitor's session. Capture the real _ga value.
Common mistakes
- Putting the API secret in browser JavaScript, where anyone can read it. Keep it on the server.
- Sending a purchase from both the browser and the server without the same transaction_id, which doubles revenue.
- Forgetting currency on revenue events.
Questions
Measurement Protocol or server-side GTM?
Measurement Protocol is ideal for backend events like CRM stages or confirmed orders. Server-side GTM is better for routing all website events to several platforms.
Can I send events for past dates?
Measurement Protocol accepts a timestamp, but only within a short window in the past, so send events promptly.
Need backend events in GA4?
I connect your backend, CRM or checkout to GA4 with the Measurement Protocol or server-side GTM, with clean IDs so nothing is double counted.