Skip to main content

GA4 Integration

GA4

Configure GA4 server-side forwarding from Selwise event stream with mapping and filter controls.

Audience: Analytics engineers and marketing teams using GA4 as primary measurement platform.

Critical: GA4 provider key is ga4 and is configured through PUT /api/v1/sites/:siteId/integrations/ga4.

Who This Page Is For

Use this page when you need to forward Selwise events to GA4 with explicit mapping, filtering, and test workflows.

Quick Start (2-5 Minutes)

1

Set GA4 config

Provide measurementId and optional apiSecret.

PUT /api/v1/sites/:siteId/integrations/ga4
2

Add event mapping

Map Selwise canonical events to GA4 event names.

{ "eventMapping": { "purchase": "purchase", "add_to_cart": "add_to_cart" } }
3

Add optional filters

Forward only events that pass conditional rules.

{ "eventFilters": { "purchase": { "enabled": true, "conditions": [{ "field": "order.total", "operator": "gte", "value": 1 }] } } }
4

Test connection

Run test endpoint to validate connectivity.

POST /api/v1/sites/:siteId/integrations/ga4/test
5

Inspect logs

Review delivery logs for failures and payload diagnostics.

GET /api/v1/sites/:siteId/integrations/ga4/logs?limit=50

GA4 config example

{
"enabled": true,
"config": {
  "measurementId": "G-XXXXXXXXXX",
  "apiSecret": "GA4_API_SECRET"
},
"eventMapping": {
  "page_view": "page_view",
  "search_query": "search",
  "add_to_cart": "add_to_cart",
  "purchase": "purchase"
},
"testMode": false
}

Required Fields / Minimum Payload

FieldRequiredTypeUsed by eventsDescription
enabledOptionalbooleanGA4 update payloadTurns GA4 forwarding on or off.
config.measurementIdRequiredstringGA4 update payloadGA4 measurement stream ID.
config.apiSecretOptionalstringGA4 update payloadSecret for Measurement Protocol-style forwarding.
eventMappingOptionalRecord<string,string>GA4 update payloadSelwise-to-GA4 event mapping table.
eventFiltersOptionalRecord<string,filter>GA4 update payloadConditional forwarding rules by event type.

Currency Behavior

  • GA4 payload currency is resolved with fallback order: event -> order -> site -> EUR.
  • Hardcoded USD fallback is not used in provider forwarding.
  • Revenue/value fields should be emitted with the resolved currency only.

Event or Endpoint Decision Matrix

ScenarioUse ThisWhy
Initial GA4 setupPUT /integrations/ga4Single source of truth for GA4 config.
Connectivity validationPOST /integrations/ga4/testEnsures credentials and channel health.
Production failure diagnosisGET /integrations/ga4/logsDetailed delivery status visibility.
Need baseline mapping templateGET /integrations/ga4/mappingsProvider default mapping reference.
Need temporary no-send validationtestMode=trueAudit payload flow without external sends.

Common Errors and Fixes

GA4 test fails with auth/config error

Cause: measurementId or apiSecret invalid for target property.

Fix: Re-issue credentials and rerun provider test.

Some events absent in GA4

Cause: Missing eventMapping entries or restrictive filters.

Fix: Map all required canonical events and review filter conditions.

Unexpected event naming in GA4

Cause: Custom mapping overwriting expected names.

Fix: Align mapping with GA4 naming convention strategy.

Traffic visible in logs only

Cause: testMode left enabled.

Fix: Disable testMode after validation.

Production Checklist

  • measurementId and apiSecret are validated with live test call.Required
  • Canonical purchase and cart events are explicitly mapped.Required
  • eventFilters are minimal and documented to avoid accidental drops.Required
  • testMode is disabled in production.Required
  • GA4 delivery logs are monitored during release windows.Required

Next Steps