Reputation: 23
I do a call to
await analyticsDataClient.runRealtimeReport({
entity: {
propertyId: propertyId,
},
dateRanges: [
{
startDate: '2020-03-31',
endDate: 'today',
},
],
dimensions: [
{
name: 'city',
},
],
metrics: [
{
name: 'activeUsers',
},
],
});
but this return the following error:
A property in the form 'properties/1234' where '1234' is a GA4 property Id is required
I think it is because my object inside my runRealtimeReport
function is wrong but I don't know how to put in.
Upvotes: 1
Views: 2531
Reputation: 1289
To create a realtime report, you need to update the request to be similar to
const propertyId = 'YOUR-GA4-PROPERTY-ID';
const [response] = await client.runRealtimeReport({
property: 'properties/' + propertyId,
dimensions: [{ name: 'city', },],
metrics: [{ name: 'activeUsers', },],
});
Please replace the 'YOUR-GA4-PROPERTY-ID' with your numeric property ID. This page describes where to find your GA4 property ID.
Realtime reports do not need dateRanges. Realtime reports are always for the last 30 minutes for your App or Website. There is more information about creating realtime reports on this page.
Upvotes: 2