Skip to content
adscapi

GA4 (Google Analytics) CAPI Payload Preview

The server-side request adscapi builds when you track() a purchase and GA4 (Google Analytics) is configured. Secrets and hashed values show as placeholders.

Request

POST
Endpoint
https://www.google-analytics.com/mp/collect?measurement_id={GA4_MEASUREMENT_ID}&api_secret={GA4_API_SECRET}
Headers
Content-Type: application/json
Body (purchase example)
{
  "client_id": "<hashClientId(order_1001)>",
  "consent": {
    "ad_user_data": "GRANTED",
    "ad_personalization": "GRANTED"
  },
  "events": [
    {
      "name": "purchase",
      "params": {
        "transaction_id": "order_1001",
        "value": 49.99,
        "currency": "USD"
      }
    }
  ]
}

Verified against the library dispatcher (src/dispatchers/ga4.ts). See the GA4 (Google Analytics) setup guide for where to get each secret.

Required secrets

GA4_MEASUREMENT_IDGA4_API_SECRET

GA4 (Google Analytics) activates when every secret is present. One missing key and the platform no-ops — the rest still receive the event.

Event-name mapping

Canonical eventGA4 (Google Analytics) receives
page_viewpage_view
leadgenerate_lead
signup_startsignup_start (custom event passthrough)
signupsign_up
checkout_createdbegin_checkout
purchasepurchase
reply_generatedreply_generated (custom event passthrough)
upgrade_clickedupgrade_clicked (custom event passthrough)

Good to know

  • Both secrets go in the URL as measurement_id and api_secret query params; the body carries no credential.
  • Analytics, not an ad CAPI: no consent gate on dispatch. Consent is signalled in the payload as GRANTED or DENIED.
  • No PII is sent. client_id is a hash of externalId (or the event id); user_id is added only when externalId exists.
  • Event property keys matching /email|password|token|secret|api_key|authorization/i are stripped before sending.

Frequently Asked Questions

Related Tools

Discover more free tools to fix your tracking

Event Payload Playground

Pick a canonical conversion event, fill the fields, and see the exact JSON payload adscapi builds — before you write a line of code.

Try it now

PII Hash Previewer

Type a raw email or phone number and see the normalized value plus its SHA-256 hash — the exact rules adscapi applies per platform. Nothing leaves the browser.

Try it now

Platform Coverage Explorer

Search all 26 ad platforms adscapi dispatches to — support level, required secrets, and setup docs, always in sync with the library registry.

Try it now

Ready to track GA4 (Google Analytics) conversions server-side?

adscapi is free and open source. Set your platform tokens, call track() once, and every configured Conversions API receives the event — hashed the way each platform expects.