GA4 - Measurement Protocol Issue - gtag + client_id + session_id not merge on reports

494 views Asked by At

We have migrated the UA to GA4. We use gtag.js for most of the events on the website and the Measurement Protocol for the purchase.

We noticed that the measurement protocol event has a problem with reporting at the sessions level on channels grouping because everything is classified as "not set", and we have a significant amount of purchases that are not linked to client_id. We are collecting a unique hit with the purchase (print screen attached).

We followed all the requirements on the documentation, and after discussions with other web analytics, it should be an issue with the Measurement Protocol.

We need your assistance to find a solution to this tracking problem.

url = "https://www.google-analytics.com//mp/collect?api_secret=API_Secrect&measurement_id=G-0000000000"
payload = {
  "client_id": "685297041.1666940000",
  "user_id": "#1234",
  "non_personalized_ads": 'false',
  "user_properties":{
    "cust_numb":{
      "value":"#1234"},
    "internal_user":{
      "value":"false"}},
  "events": [
    {
      "name": "purchase",
      "params": {
        "items": [
          {          
            "price": 3.35,
            "quantity": 1,
            "item_id": "#1062",
            "item_name": "White Fine Filters",
            "affiliation": "client.com",
            "currency": "USD",
            "discount": 0.5,
            "item_variant": "NA",
            "item_category": "Filters",
            "item_brand": "Generic",
            "index": 0,
            "item_category2": "One_Time",
            "item_category3": "simple_product",
            "item_category4": "full_price",
            "item_category5": "in stock"
          },
          {
            "price": 15.95,
            "quantity": 1,
            "item_id": "#1068",
            "item_name": "Black Filters for PR",
            "affiliation": "client.com",
            "currency": "USD",
            "discount": 5.8,
            "item_variant": "NA",
            "item_category": "Supplies/Filters/Sale 2021",
            "item_brand": "Generic",
            "index": 1,
            "item_category2": "one_time",
            "item_category3": "simple_product",
            "item_category4": "Discounted",
            "item_category5": "in_stock"
          }],
        "affiliation": "",
        "coupon": "ALL10",
        "currency": "USD",
        "transaction_id": "#2_02022",
        "shipping": 5,
        "tax": 0.35,
        "value": 15,
        "session_id": "1666947000",
        "timestamp_micros": "1666948174531000",
        "engagement_time_msec": "1000"
       }
    }
  ]
}

requests.post(url,data=json.dumps(payload))

enter image description here

I tested everything.

Could you let me know if you are facing the same issue?

I noticed this on the documentation, but it's not detailed what partial reporting is.

"Full Server-to-Server While it is possible to send events to Google Analytics solely with measurement protocol, only partial reporting may be available. The purpose of the measurement protocol is to augment existing events collected via gtag, GTM, or Firebase. Some event and parameter names are reserved for use via automatic collection and cannot be sent through the measurement protocol."

Thank you,

1

There are 1 answers

0
Stephan Böni On

session_id and engagement_time_msec must be numeric (without quotes)

"session_id": 1666947000,
"engagement_time_msec": 1000