-
Notifications
You must be signed in to change notification settings - Fork 89
Getting Results
rodrigoalvesvieira edited this page Aug 10, 2011
·
18 revisions
First, get a profile:
profile = Garb::Management::Profile.all.first
You can also get an exact profile by passing its Web Property id:
profile = Garb::Management::Profile.all.detect {|p| p.web_property_id == 'UA-00000000-0'}
Then define an Exits class, extending Garb::Model and gathering metrics for pageviews:
class Exits
extend Garb::Model
metrics :pageviews
end
Then fetch the results:
Exits.results(profile, :limit => 10,
:offset => 20,
:start_date => (Date.today - 30),
:end_date => Date.today,
:filters => {:pageviews.gte => 200},
:sort => :pageviews)
The shorthand with a given profile is also nice:
profile.exits(:limit => 10, :offset => 20)
This can be done with any class which extends Garb::Model
Note that contains accepts a regex notation but as a string rather than a actual regex literal. For example, to get results for all pages with a path containing “blog/posts/any-post-title” use this:
Exits.results(profile, :filters => {:page_path.contains => "^\/blog\/posts\/.+" })
Instead of:
Exits.results(profile, :filters => {:page_path.contains => /^\/blog\/posts\/.+/ })