maintenanceVN
maintenanceVN

Reputation: 51

Analytics GA4 - call Api for custom dimension

I try to call custom dimension from Analytics GA4 and my php script don't recognize the customEvent name. The custom event is recorded in google analytics 4 and GTM, it's even recognize in the tool GA4 query explorer https://ga-dev-tools.web.app/ga4/query-explorer/

$response_type_event = $client_type_event->runReport([
        'property' => 'properties/' . $property_id,
        'dateRanges' =>
            [
                new DateRange(
                    [
                        'start_date' => '2022-09-01',
                        'end_date' => '2022-09-30',
                    ]
                ),
            ],
        'dimensions' =>
            [
                new Dimension(
                    [
                        'name' => 'customEvent:clic_pub_catalog_id'
                    ]
                ),
            ],
        'metrics' =>
            [
                new Metric(
                    [
                        'name' => 'eventCount',
                    ]
                )
            ]
    ]);

In my terminal i get this error when i run my script :

.../vendor/google/gax/src/ApiException.php on line 267

Fatal error: Uncaught Google\ApiCore\ApiException: {
    "message": "Field customEvent:clic_pub_catalog_id is not a valid dimension. For a list of valid dimensions and metrics, see https:\/\/developers.google.com\/analytics\/devguides\/reporting\/data\/v1\/api-schema ",
    "code": 3,
    "status": "INVALID_ARGUMENT",
    "details": []
}

And the documentation of google don't help me to get through this. https://developers.google.com/analytics/devguides/reporting/data/v1/advanced#event-scoped_custom_dimensions

Does anyone have a good tips to solve this problem please?

Upvotes: 3

Views: 1752

Answers (1)

Alex Yatsenko
Alex Yatsenko

Reputation: 31

The Data API real-time reporting documentation mentions that "Event-scoped custom dimensions are not currently supported in the Realtime API".

https://developers.google.com/analytics/devguides/reporting/data/v1/realtime-api-schema

Upvotes: 1

Related Questions