Search code examples
rgoogle-analytics-api

how to fix "Error in ParseDataFeedJSON(GA.Data) : code : 400 Reason : Invalid expression. Expression exceeds max size of 4096"


I am trying to get the eventLabels from the google analytics api through R

I tried reducing the number of max.results in the Init() function. I still keep getting the error

# get eventLabel which is a unique video ID of the video on the website.
query.list <- Init(startDate,
                   endDate,
                   dimensions = "ga:eventLabel",
                   metrics = "ga:totalEvents",
                   filters = reportFiltersCOVE,
                   max.results = 10000,
                   table.id = tableID_events)
# run query
ga.query <- QueryBuilder(query.list)
# save data for google analytics in data.nko.COVE
data.nko.COVE <- GetReportData(ga.query,
                               gaOAuth_token)

I get the following error

"Error in ParseDataFeedJSON(GA.Data) :    code : 400 Reason : Invalid expression. Expression exceeds max size of 4096"

when I run the last piece of code

data.nko.COVE <- GetReportData(ga.query,
                               gaOAuth_token)

I need help in understanding what this error means and how can I fix it?"

Any help is much appreciated


Solution

  • I'm guessing this error is referring to the string length of the your filter Expression.

    I think if you count the number of characters of 'reportFiltersCOVE' it will exceed the length of 4096.

    However I was not able to find any documentation on the limit for the filter field. https://developers.google.com/analytics/devguides/reporting/core/v3/reference#filter

    Can you try again with a shorter filter expression?