Question

ga:daysSinceLastSession >= 20

says. 400 : Invalid value 'ga:daysSinceLastSession >= 20' for filters parameter.

But according to the manual that's way you should do it. So what am I doing wrong here?

https://www.googleapis.com/analytics/v3/data/ga?ids=REMOVED&dimensions=ga%3AdaysSinceLastSession&metrics=ga%3Ausers&segment=gaid%3A%3A-14&filters=ga%3AdaysSinceLastSession%20%3E%3D%2020&start-date=2014-05-12&end-date=2014-05-14&max-results=50
Was it helpful?

Solution

ga:daysSinceLastSession is a dimension. Dimensons can only be filtered on

  • == Exact match
  • != Does not match
  • =@ Contains substring
  • !@ Does not contain substring
  • =~ Contains a match for the regular expression
  • !~ Does not match regular expression !~

Answer: 'ga:daysSinceLastSession >= 20' is an invalid use of a filter because you cant do >= on a dimension.

Link to filters with the Core reporting api: Filteres

Edit: The only option I can think of would be a very scary filter something like ga:daysSinceLastSession==10,ga:daysSinceLastSession==11,ga:daysSinceLastSession==12

Note: I'm not sure how long a filter can be documentation says 128 characters for regular expression filters but I'm not sure if that limit will apply here. But the max length of a URL is 2000 characters so you will have to test the max length of your request string as you build it.

OTHER TIPS

Data Type for daysSinceLastSession is String, so I guess a mathematical operator won't work (equality operator works fine in the query explorer). I think you'd have to go for an regular expression (at least two numbers, first numbers 2 or larger).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top