Skip to content

Instantly share code, notes, and snippets.

@tysone
Created September 15, 2011 20:43
Show Gist options
  • Save tysone/1220423 to your computer and use it in GitHub Desktop.
Save tysone/1220423 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'garb'
Garb::Session.login(username,password)
class Popular
extend Garb::Model
metrics :pageviews
dimensions :page_path, :page_title
end
profile = Garb::Management::Profile.all.detect {|p| p.web_property_id == 'UA-7885722-22'}
options = {
:limit => 10,
:sort => :pageviews.desc,
:start_date => (Date.today - 2),
:end_date => Date.today,
:filters => {
:page_path.contains => "^\/schoolbook\/[0-9]{4}.+"
}
}
profile.popular(options).each do |page|
puts page.pageviews
puts page.page_path
puts page.page_title.gsub(' – SchoolBook','')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment