Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Google Analytics API: filter with AND is impossible #37

sqrrrl opened this Issue · 1 comment

1 participant



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:

  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"?

Fixed for 0.7 (soon)

@sqrrrl sqrrrl closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.