-
Notifications
You must be signed in to change notification settings - Fork 89
Filtering
Filtering can be accomplished when asking for results from a class which extends Garb::Model
Exits.results(profile, :filters => {:pageviews.gte => 200})
If you want to have multiple filters AND’d together:
Exits.results(profile, :filters => {:pageviews.gte => 200, :pageviews.lte => 1000})
If you want to have multiple filters OR’d together:
Exits.results(profile, :filters => [{:page_path.contains => '/research'}, {:page_path.contains => '/library'}])
You can even have multiple AND’s that get OR’d together:
Exits.results(profile, :filters => [{:pageviews.gte => 200, :pageviews.lte => 1000}, {:page_path.contains => 'research', :page_path.does_not_contain => 'library'}])
Unfortunately, there are a few limitations to this approach considering the data structures in use. For example, we cannot have OR’s that are AND’d together because an Array can not simply be placed in a hash. It needs a key. However, the Garb would have to ignore the key, and so the key would simply be noise.
A new filtering interface is in the works. Please try out the “filtering” branch to see how it is coming along.
Google Analytics supports a significant number of filtering options.
http://code.google.com/apis/analytics/docs/gdata/gdataReference.html#filtering
Here is what we can do currently: (the operator is a method on a symbol for the appropriate metric or dimension)
Operators on metrics:
- eql => ‘==’,
- not_eql => ‘!=’,
- gt => ‘>’,
- gte => ‘>=’,
- lt => ‘<’,
- lte => ‘<=’
Operators on dimensions:
- matches => ‘==’,
- does_not_match => ‘!=’,
- contains => ‘=~’,
- does_not_contain => ‘!~’,
- substring => ‘=@’,
- not_substring => ‘!@’