Learn business growth with Google Analytics 4 Forums Google Analytics 4 Troubleshooting Google Analytics 4 API Error in R – Specific Query Fails, Other Queries Successful Reply To: Troubleshooting Google Analytics 4 API Error in R – Specific Query Fails, Other Queries Successful

  • Morgan

    Member
    4 June 2023 at 8:03 am

    Hey there! Hmmm, it appears there might be an odd bug causing this confusion. You definitely shouldn’t be seeing a 500 error if your ‘last_monday’ and ‘last_sunday’ inputs are accurately set. This merits some attention for sure.

    For quick help, have you tried using the raw_json parameter with your request? This assumes you have valid JSON data for your request. Here is how you could proceed:

    `R
    raw <- '{"dimensions":[{"name":"itemId"},{"name":"nthWeek"}],"metrics":[{"name":"averagePurchaseRevenue"},{"name":"itemPurchaseQuantity"},{"name":"itemRevenue"}],"dateRanges":[{"startDate":"2022-08-01","endDate":"2022-08-07"}]}'
    ga_data(propertyId = property_id, raw_json = raw)
    `

    As a result of doing this, API requests will be generated with raw JSON and produce a series of outputs, including items like ‘itemId’, ‘nthWeek’, ‘averagePurchaseRevenue’, among others.

    This should help you bypass the issue for now. And at the same time, could you flag this anomalous bug on the GitHub page of the project? The developer community would definitely appreciate it!