Created
November 6, 2012 04:12
-
-
Save SeanJA/4022494 to your computer and use it in GitHub Desktop.
pageviews widget for dashing
This file contains 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
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1"> | |
<div data-id="daily_pageviews" data-view="Number" data-title="Page Views" data-moreinfo="Today"></div> | |
</li> | |
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1"> | |
<div data-id="monthly_pageviews" data-view="Number" data-title="Page Views" data-moreinfo="Today"></div> | |
</li> |
This file contains 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
gem 'garb', :git => 'git://github.com/Sija/garb.git' |
This file contains 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
require 'garb' | |
username = '' | |
password = '' | |
api_key = '' | |
ua = '' | |
Garb::Session.api_key = api_key | |
Garb::Session.login(username, password) | |
class PageViews | |
extend Garb::Model | |
metrics :pageviews | |
dimensions :date | |
end | |
profile = Garb::Management::Profile.all.detect {|p| p.web_property_id == ua} | |
SCHEDULER.every '1m', :first_in => 0 do | |
views = PageViews.results( | |
profile, | |
:start_date => Time.now, | |
:end_date => Time.now, | |
:limit => 1 | |
) | |
value = views.first.pageviews | |
send_event('daily_pageviews', { current: value }) | |
end |
This file contains 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
require 'garb' | |
username = '' | |
password = '' | |
api_key = '' | |
ua = '' | |
Garb::Session.api_key = api_key | |
Garb::Session.login(username, password) | |
class PageViews | |
extend Garb::Model | |
metrics :pageviews | |
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 | |
) | |
value = views.first.pageviews | |
send_event('monthly_pageviews', { current: value }) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I went with the monthly one myself, but if you have a high-traffic site, you might want to go with the daily one