This is a fork with support of the latest google api of the Google Analytics Website Visitor Count Widget for Dashing with OAuth2 Authentication to allow for multiple profiles to be shown in the same widget.
A Dashing widget for displaying the number of visitors to your website over a specified timeframe, as reported by Google Analytics
Add it to dashing's gemfile:
gem 'google-api-client'
and run bundle install
.
To use this widget, you'll first need to set up a Google API project and attach it to the Google Analytics profile you wish to monitor.
- Go to https://code.google.com/apis/console
- Click 'Create Project'
- Enable 'Analytics API' service and accept both TOS's
- Click 'API Access' in the left-hand nav menu
- Click 'Create an OAuth 2.0 Client ID'
- Enter a product name (e.g. Dashing Widget) - logo and url are optional
- Click 'Next'
- Under Application Type, select 'Service Account'
- Click 'Create Client ID'
- Click 'Download private key' (JSON!) NOTE: This will be your only opportunity to download this key.
- Close the download key dialog
- Find the details for the service account you just created and copy it's email address which will look something like this:
[email protected]
- you'll need it in your ruby code later
Note: you will need to be an administrator of the Google Analytics profile
- Log in to your Google Analytics account: http://www.google.com/analytics/
- Click 'Admin' in the upper-right corner
- Select the account containing the profile you wish to use
- Select the property containing the profile you wish to use
- Select the profile you wish to use
- Click the 'Users' tab
- Click '+ New User'
- Enter the email address you copied from step 13 above
- Click 'Add User'
- On your Google Analytics profile page, click the 'Profile Settings' tab
- Under 'General Information' copy your Profile ID (e.g. 654321) - you'll need it in your ruby code later
-
Copy the
visitor_count.rb
file in to your dashingjobs\
folder. -
Update the
profile_id
and set ENVIRONEMTN variabel GOOGLE_APPLICATION_CREDENTIALS to your google-service-account.json file -
Add the widget HTML to your dashboard
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="visitor_count" data-view="List" data-unordered="true" data-title="Visitors This Month"></div>
</li>
If you want to modify this plugin to pull other data from Google Analytics, be sure to check out the Google Analytics Query Explorer.