google-analyticsmeasurement-protocolcustom-dimensions

GA4 custom dimensions with "event" scope is showing as "not set" in GA


I'm trying to solve a mystery why 2 of 5 custom dimensions of a offline purchase data are showing as "not set" in Google Analytics 4. That might have something to do with a scope of a CD, the ones that have "user" reach GA with no problem. Problematic ones are of "event" scope: invoice_id (cd4) and information about if it is a first purchase of a client or not (cd3).

I'm sending all data from a postman:

{
    "client_id": "1308202317.1678091000",
    "user_id": "1000",
    "non_personalized_ads": false,
    "user_properties": {
        "cd1": {
            "value": "1308202317.1678091000"
        },
        "cd2": {
            "value": "1000"
        },
        "cd3": {
            "value": "ConsequentPay"
        },
        "cd4": {
            "value": "230100953"
        },
        "cd5": {
            "value": "1001"
        }
    },
    "events": [
        {
            "name": "purchase",
            "params": {
                "items": [
                    {....

                ],
                "currency": "CZK",
                "value": 8500
            }
        }
    ]
}

Cd1,2,5 are showed in the reports. Cd3,cd4 are either greyed out or displayed as "not set".

CD parameters are over 48 hours old, should be showing correctly. cd3 and 4 parameters were succsessfully recorded in GA3 as "Hit" scope, which is "Event" in GA4.


Solution

  • Ok, managed to solve this issue: whenever you have an event-type custom definition, you have to report it inside "events", not "user_properties":

    {
        "client_id": "1308202317.1678091000",
        "user_id": "1000",
        "non_personalized_ads": false,
        "user_properties": {
            "cd1": {
                "value": "1308202317.1678091000"
            },
            "cd2": {
                "value": "1000"
            },
            "cd5": {
                "value": "1001"
            }
        },
        "events": [
            {
                "name": "purchase",
                "params": {
                    "items": [
                        {....
    
                    ],
                    "currency": "CZK",
                    "cd3": "ConsequentPay",
                    "cd4": "230100953",
                    "value": 8500
            },
                }
            }
        ]
    }