GA4 Measurement Protocol Payload Builder

Build server-side GA4 Measurement Protocol v2 payloads for backend events (purchase confirmations, refunds, offline conversions). Includes code snippets for cURL, Node.js, Python, and PHP.
Measurement Intelligence
Server-side events survive ad blockers, iOS tracking prevention, and incognito browsing.
For high-value conversions (purchases, refunds, lead qualifications), relying on client-side tags alone loses 15–30% of data. The Measurement Protocol lets your backend send events directly to GA4. bypassing all browser-side blocking. Requires a Measurement ID and an API Secret (generate in GA4 Admin and Data Streams).
Credentials
Get these from GA4 and Admin and Data Streams and Select Stream and Measurement Protocol API secrets. Secrets stay in your browser: nothing is sent to our servers.
Event payload
Build the request body
client_id *
non_personalized_ads
Event
The event body as a JSON object. Will be nested under events[0].params.
Validation
Request body (JSON)

        
Server-side implementations
Pick your language

        
      
Next steps
Debug server-side events before going live
Send to the Google-provided debug endpoint first (append ?debug=1 or use /mp/collect + validation_mode: true) to catch issues before data lands in production.
Frequently asked questions
What is Measurement Protocol?
GA4's server-side API for sending events. Replaces client-side gtag calls. Essential for server-side tracking, offline conversions, and post-iOS attribution.
When should I use Measurement Protocol?
Server-side GTM, offline conversion import, back-end events (subscription renewals, support ticket flows), post-iOS tracking recovery.
What are the required parameters?
measurement_id, api_secret, client_id, event name. Event parameters optional but recommended.
Where do I get the api_secret?
GA4 and Admin and Data Streams and your stream and Measurement Protocol API secrets. Create one, store securely.
What about client_id?
The GA4 user identifier. For first-party events get it from the _ga cookie or generate a UUID per server session.
How many events per request?
Up to 25 events per request. Batch for efficiency.
Can I backfill historical events?
Yes but limited to within 72 hours. Beyond that GA4 may reject or discount.
How to test Measurement Protocol?
GA4 and Admin and Debug mode. Use ?debug_mode=1 on the client_id or send to the debug endpoint.
What languages does the generator output code for?
cURL, Node.js, Python, PHP. Covers 90% of server environments.
Does Measurement Protocol work for GA4 Audiences?
Yes. Events sent via MP contribute to audience membership exactly like client-side events.
What about Enhanced Measurement events?
Those are triggered automatically by the GA4 tag (scroll, outbound click, etc.). Measurement Protocol is for your own events.
Free · no account

SEORCE for Chrome, Edge and Firefox

Audits the page you are on: headings, meta tags, schema, indexability, and whether AI crawlers can read it. Export the result as a PDF. Free, with no account.

It audits one page at a time and does not track AI answers. About the extension

Traffic from search and AI

See which visits came from search and AI.

SEORCE Web Analytics runs from one script tag, with Google Search Console connected. It shows visits from every AI source, from search and from campaigns, and it is free on every plan.
3,000+ users · Free forever plan, no card needed