1

GA4 purchase events are sent from client server via measurement protocol. But there is no session_id parameter in the queries, because of that source and medium is lost. We tried to pass the session_id parameter in MP request, but no data were received.

Example of submitted request:

{
 "timestamp_micros": "1664522406546590",
 "non_personalized_ads": false,
 "events": [
  {
   "name": "purchase_balance_top_up",
   "params": {
    "user_id": "11111111",
    "crm_id": "11111111",
    "balance": 990,
    "payment_method": "paymore"
   }
  }
 ],
 "client_id": "1119492379.1652295143",
 "session_id": "1664522264",
 "user_id": "11111111"
}

Attaching a screenshot of the raw data from BigQuery on events sent by MP. Screenshot of the raw data from BigQuery

Help, how to properly pass the session_id? Or how to make sure that events don't lose source param?

3 Answers3

2

We found a solution to the problem. It's simple. The parameter "session_id" must be passed inside the array "params" of the event.

Here is an example of the correct event data array to be sent via measurement protocol:

{
 "timestamp_micros": "1664522406546590",
 "non_personalized_ads": false,
 "events": [
  {
   "name": "purchase_balance_top_up",
   "params": {
    "user_id": "11111111",
    "crm_id": "11111111",
    "balance": 990,
    "payment_method": "paymore",
    "session_id": "1664522264"
   }
  }
 ],
 "client_id": "1119492379.1652295143",
 "user_id": "11111111"
}
1

For people that are looking for the final answer on this: session_id is now officially part of the measurement protocol but the documentation on it is lacking.

However it has been confirmed through the GA4 MP changelog here: https://developers.google.com/analytics/devguides/collection/protocol/ga4/changelog

0

Actually we are sending purchase events similarly with such request:

{
    "client_id": "xxx.xxx",            
    "user_id" : "xxxx",                   
    "non_personalized_ads": false,
    "user_properties": {
    "user_id_dimension": {
      "value": "xxxx"                    
    }
   },
    "events": [{
      "name": "purchase",
      "params": {
        "currency": "USD",
        "transaction_id": "T_12345",     
        "value": 12.21,
        "engagement_time_msec": 10,
        "session_id": "XXXXXXXXXX",                                                                                                                         
        "items": [
          {                               
            "item_name": "Top-up"                
          }
        ]
      }
    }]
  }

but we are not sending timestamp_micros. And we send 'user_id_dimension' as user property with the same value as 'user_id' parameter to observe user id further in Exploration reports. We've created user-scoped custom dimension in GA4 interface with dimension name User ID and this user property 'user_id_dimension'. Everything works

Mitrodol
  • 11
  • 3