Skip to content

Instantly share code, notes, and snippets.

@gumayunov
Created May 20, 2010 20:42
Show Gist options
  • Save gumayunov/408071 to your computer and use it in GitHub Desktop.
Save gumayunov/408071 to your computer and use it in GitHub Desktop.
token = "DQAAAJMAAAD6eA_yqsc...KsqsmQ3SmntxMtAaWg9jO_OJvJNCXkfhBtfp"
ga = Gattica.new(
:token => token,
:headers => {'Authorization' => "GoogleLogin auth=#{token}"},
:profile_id = 4689690
)
res = ga.get(
:start_date => '2010-05-18',
:end_date => '2010-05-19',
:dimensions => ['pagePath'],
:metrics => ['pageviews','newVisits'],
:sort => ['-pageviews'],
:filters => ['pagePath=~^\/20\d\d']
)
res.to_csv(:short).split("\n").map do |line|
Hash[[:path, :pageviews, :newvisits].zip line.split(/,/)]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment