Skip to content

Google Analytics API: filter with AND is impossible #57

@GoogleCodeExporter

Description

@GoogleCodeExporter
What steps will reproduce the problem?
1. @client = Google::APIClient.new (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 = Google::APIClient::Reference.new(:api_method => 
analytics.data.ga.get(), :parameters => parameters)
3. request = @client.generate_request(reference)
4. 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? 
"filters"=>"ga:medium=~cpa|cpc|cpm|cpp|cpv|ppc;ga:source==google"

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)

Please provide any additional information below.

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 ?

Original issue reported on code.google.com by aramb...@optimeez.com on 31 Aug 2012 at 9:02

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions