How can I measure session/users with the GA4 Measurement Protocol?

Viewed 357

The documentation for the GA4 measurement protocol only describes sending events, and notes that the key events for measuring session duration etc. are reserved (automatically provided by gtag/firebase).

I'm attempting to use the measurement protocol in a .NET desktop environment (not firebase/web/android/ios). Sending events works as expected (they show up on the dashboard), but the user count always shows as zero. Sending a session_started event to the debug endpoint does not pass validation (states that it is a reserved event name).

Is it possible to manually send the events required to track sessions or is there another way to get an accurate user count without using firebase/gtag?

Protocol reference: https://developers.google.com/analytics/devguides/collection/protocol/ga4

1 Answers

You need to include the 'engagement_time_msec' parameter with a value of '1', e.g.:

{
    "client_id": "XXXXXXXXXXXX",
    "timestamp_micros": 1655281222643640,
    "events": [
        {
            "name": "page_view",
            "params": {
                "page_location": "https://test.com",
                "page_title": "Home Page",
                "engagement_time_msec": 1
            }
        }
    ]
}

This was answered here: https://stackoverflow.com/a/71482548/7205473

Related