javascriptnode.jsgoogle-analytics-api

Extreme implausible page_view counts in realtime reporting


We encounter implausible values when getting page view counts as realtime figures compared to page views as reporting figures.

The reporting events are queried like so:

let [response] = await analyticsDataClient.runReport({
        property: `properties/${propertyId}`,
        dimensions: [{ name: 'eventName' }],
        metrics: [{ name: 'eventCount' }],
        dateRanges: [{ startDate: 'yesterday', endDate: 'yesterday' }],
        dimensionFilter: { filter: { inListFilter: { values: ['page_view', 'user_engagement'] }, fieldName: 'eventName' } }
    });
response.rows.forEach(row => {
        console.log(row.dimensionValues[0].value, row.metricValues[0].value);
    });

Output:

user_engagement 100531
page_view 69337

We retrieve realtime events like so:

let [response] = await analyticsDataClient.runRealtimeReport({
        property: `properties/${propertyId}`,
        dimensions: [{ name: 'eventName' }],
        metrics: [{ name: 'eventCount' }],
        dimensionFilter: { filter: { inListFilter: { values: ['page_view', 'user_engagement'] }, fieldName: 'eventName' } }
    });
response.rows.forEach(row => {
    console.log(row.dimensionValues[0].value, row.metricValues[0].value);
});

Output:

user_engagement 2327
page_view 6

The ratio between very low page_view and realistic user_engagement values remain quite the same when running the realtime report at different times of day.

It's obvious that realtime page_view values seem to be completely wrong. They should be about 70 % of the user_engagement count.

Question: is this a bug in GA? If yes, what can I do about it? If no, what am I missing?


Solution

  • The root cause of this issue was cookie consent configuration. page_view event has been submitted to GA with a lower consent state than user_engagement event.

    We fixed this by moving the cookie banner script upwards in the HTML head.

    See the full answer here.