Google Analytics API: filter with AND is impossible #37

sqrrrl opened this Issue Apr 8, 2013 · 1 comment


None yet

1 participant

sqrrrl commented Apr 8, 2013


What steps will reproduce the problem?

  1. @client = (then -> authorize)
  2. parameters={"ids"=>"ga:XXXXX", "start-date"=>"2011-07-30", "end-date"=>"2012-08-30", "metrics"=>"ga:visits", "filters"=>"ga:medium=~cpa|cpc|cpm|cpp|cpv|ppc;ga:source==google"}
  3. reference = =>, :parameters => parameters)
  4. request = @client.generate_request(reference)
  5. you will see that in request object, the 'filters' parameter is split in 2:
    "filters"=>"ga:medium=~cpa|cpc|cpm|cpp|cpv|ppc", "ga:source"=>"=google"

What is the expected output?


What do you see instead?

"filters"=>"ga:medium=~cpa|cpc|cpm|cpp|cpv|ppc", "ga:source"=>"=google"

What version of the product are you using? On what operating system?

  • Google Analytics Core reporting API V3
  • ruby 1.9.3
  • google-api-ruby-client : hedge (git)

The problem comes from Faraday (or Google Analytics Core reporting API V3 syntax for filters) 👍

  1. in Faraday::Utils, DEFAULT_SEP = /[&;] */n
  2. so the method ''parse_nested_query" splits the part
    "&filters=ga:medium=~cpa|cpc|cpm|cpp|cpv|ppc;ga:source==google" in {"filters" => "ga:medium=~cpa|cpc|cpm|cpp|cpv|ppc", "ga:source" => "=google"}

One solution would be to open Faraday and edit DEFAULT_SEP (remove the ';'): DEFAULT_SEP = /[&] */n
How can we deal with this ?

Aug 31, 2012
I really need to have a chat with the rest of the Ruby community on how to process URIs.

Mar 18, 2013
I'd like to do what I can to make the appropriate change happen in Faraday. A few questions:

  1. Is there an issue open in Faraday to reflect that this problem is happening?
  2. Is it a typo in the URL that the URL includes "ga:source==google"? Should that just be a single equals? That is, is "=google" the value of the "ga:source" parameter, or is it "google"?
sqrrrl commented Jun 7, 2013

Fixed for 0.7 (soon)

@sqrrrl sqrrrl closed this Jun 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment