Cherry Seed

How do I connect server events to user sessions?

GA4 Measurement Protocol server-side GA4 MP events

Quick Answer

Capture the client_id from the _ga cookie on the client side and pass it to your server. Include this client_id in your Measurement Protocol request. GA4 uses this ID to associate the server event with the user's browsing session. Without matching client_id, events appear as separate users.

Full Answer

Connecting server events to sessions: The client_id: GA4 assigns each browser a unique client_id, stored in the _ga cookie: Capture client-side: Pass to server: Include in checkout form or session: Send with MP request: What happens:

  • GA4 receives server event
  • Matches to existing client_id
  • Event attributed to user's session
  • Shows in user's journey If no client_id captured: Generate a new one server-side. Event won't connect to browsing session but will still be tracked. Best practice: Always try to capture and pass the real client_id for session...

Sources

Programmatic Access

GET https://seresa.io/wp-json/cherry-tree-by-seresa/v1/seeds/512

Cite This Answer

Cherry Tree by Seresa - https://seresa.io/seed/google-ads-ga4/ga4-measurement-protocol-connect-server-sessions