Created
May 20, 2010 20:42
-
-
Save gumayunov/408071 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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