-
Notifications
You must be signed in to change notification settings - Fork 48
Quick Start
Tony Pitale edited this page Jan 2, 2014
·
14 revisions
-
Install gems
> gem install legato
-
Start irb
> irb
-
Require gems
require 'legato'
-
Get an OAuth2 Token. Make sure to use the scope https://www.googleapis.com/auth/analytics.readonly.
-
Create a Model
class Exit extend Legato::Model metrics :exits, :pageviews dimensions :browser end
-
Create a User
user = Legato::User.new(access_token) # access_token from step #4
-
Select a Profile
profile = user.profiles.first
-
Query for Results
Exit.results(profile).each {|result| p result} profile.exit.each {|result| p result}
It's important to note that the method name exit
comes from the model name Exit
above. This is a shortcut. It's preferable to use the model class directly.
- Options
The results
method accepts a number of options:
start_date
end_date
limit
offset
-
sort
, for reverse sort, pass a string value with a-
as the first character e.g.,'-pageviews'
.