Last active
October 21, 2016 07:40
-
-
Save SeanJA/4992004 to your computer and use it in GitHub Desktop.
Revisions
-
SeanJA revised this gist
Jun 18, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ Set your google username `username = ''` Put in your google password (create a secondary account for this with a really long randomly generated password) `password = ''` -
SeanJA revised this gist
Feb 20, 2013 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,8 @@ You will need Sija's version of the garb gem, so add this line to your `Gemfile` `gem 'garb', :git => 'git://github.com/Sija/garb.git'` Then run the gem bundler: `bundle install` Set your google username `username = ''` -
SeanJA revised this gist
Feb 20, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ Put in your google password (you might want to create a secondary account for th `password = ''` Get an api key for google analytics from here: https://code.google.com/apis/console and set the api_key: `api_key = ''` -
SeanJA revised this gist
Feb 20, 2013 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,16 +2,23 @@ Set Up === You will need Sija's version of the garb gem, so add this line to your `Gemfile` (you will need git installed for this): `gem 'garb', :git => 'git://github.com/Sija/garb.git'` Set your google username `username = ''` Put in your google password (you might want to create a secondary account for this with a really long randomly generated password) `password = ''` Get an api key from here: https://code.google.com/apis/console and set the api_key: `api_key = ''` pick your property from the google analytics interface ( http://google.com/analytics ) and set it: `ua = ''` Then add the contents of `google_pageviews.erb` to your layout file. -
SeanJA created this gist
Feb 20, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ Set Up === You will need Sija's version of the garb gem, so add this line to your `Gemfile` (you will need git installed for this): `gem 'garb', :git => 'git://github.com/Sija/garb.git'` Set your google username `username = ''` Put in your google password (you might want to create a secondary account for this with a really long randomly generated password) `password = ''` Get an api key from here: https://code.google.com/apis/console and set the api_key: `api_key = ''` pick your property from the google analytics interface ( http://google.com/analytics ) and set it: `ua = ''` Then add the contents of `google_pageviews.erb` to your layout file. If you change the dimensions from `:month` make sure you update the `data-moreinfo` line so that it matches the interval. 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ <li data-row="1" data-col="1" data-sizex="1" data-sizey="1"> <div data-id="page_views" data-view="Number" data-title="Views" data-moreinfo="This Month" style="background-color:#869;"></div> <i class="icon-link icon-background"></i> </li> 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ require 'garb' # google username username = '' # google password password = '' # google api key api_key = '' # google analytics ua (make sure the UA- is there) ua = 'UA-' Garb::Session.api_key = api_key Garb::Session.login(username, password) class PageViews extend Garb::Model metrics :pageviews # this could be :day, :month, :year dimensions :month end profile = Garb::Management::Profile.all.detect {|p| p.web_property_id == ua} SCHEDULER.every '1m', :first_in => 0 do views = PageViews.results( profile, :limit => 1, :start_date => Date.new(Time.now.year,Time.now.month,1).to_time ) send_event('page_views', { current: views.first.pageviews }) end