Skip to content

Instantly share code, notes, and snippets.

@davidjrice
Created November 8, 2010 01:32
Show Gist options
  • Save davidjrice/667272 to your computer and use it in GitHub Desktop.
Save davidjrice/667272 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'garb'
require 'fastercsv'
ga = Garb::Session.login('USERNAME', 'PASSWORD')
Garb::Account.all.each do |account|
profile = account.profiles.first
report = Garb::Report.new(profile)
report.metrics :pageviews, :exits
report.dimensions :page_path
report.sort :exits
FasterCSV.open("./#{account.name}.csv", "w") do |csv|
csv << ["page path", "pageviews","exits"]
report.results.each do |r|
csv << [r.page_path, r.pageviews, r.exits]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment