Learn business growth with Google Analytics 4 Forums Google Analytics 4 Issue with missing dates in GA4 API response when creating daily chart

  • Issue with missing dates in GA4 API response when creating daily chart

    Posted by Elizabeth on 10 March 2023 at 1:25 am

    “I’ve been trying to create a chart report with custom dimensions using Google Analytics 4, but I’m having an issue with collecting data through API. The date data seems to be missing when I get data from GA4, which I need for building the chart. Interestingly, even though I set the dateRanges to be between { startDate: 2022-12-06, endDate: 2023-01-03 }, the only date that is being returned is 20221227. Does anyone have an idea of what the issue could be?”

    Samuel replied 1 year ago 3 Members · 2 Replies
  • 2 Replies
  • Alexander

    Member
    20 April 2023 at 8:32 am

    It seems from the Google Analytics 4 API documentation that the response body from the runPivotReport function does not directly contain date data. The API appears to assume that the user already knows the date ranges that were requested. Here’s the structure of the response body:

    `
    {
    “pivotHeaders”: [
    {
    object (PivotHeader)
    }
    ],
    “dimensionHeaders”: [
    {
    object (DimensionHeader)
    }
    ],
    “metricHeaders”: [
    {
    object (MetricHeader)
    }
    ],
    “rows”: [
    {
    object (Row)
    }
    ],
    “aggregates”: [
    {
    object (Row)
    }
    ],
    “metadata”: {
    object (ResponseMetaData)
    },
    “propertyQuota”: {
    object (PropertyQuota)
    },
    “kind”: string
    }
    `

    As you can see from this structure, there are no specific fields for the start or end dates of the date range.

  • Samuel

    Member
    8 July 2023 at 1:40 pm

    The issue might be related to how the Google Analytics 4 API is interpreting the dateRange values you are providing. Check first if the date format you are using is correct, the valid format for GA4 is “YYYY-MM-DD”. Moreover, ensure that there’s data for the whole range of dates you’ve requested. The GA4 API only returns data for the dates where there’s activity to report. If the only date being returned is 20221227, it might be because that’s the only date within your specified range that has any data. So, it’s also important to confirm that events were being properly tracked during this period. If you’re still experiencing issues, it may be worth verifying your API request and the accompanying parameters or contacting Google’s support for more specific help.

Log in to reply.