Add it to dashing's gemfile:
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' NOTE: This will be your only opportunity to download this key.
- Note the password for your new private key ('notasecret')
- 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:
firstname.lastname@example.org- 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.rbfile in to your dashing
- Update the
service_account_email = '[YOUR SERVICE ACCOUTN EMAIL]' # Email of service account key_file = 'path/to/your/keyfile.p12' # File containing your private key key_secret = 'notasecret' # Password to unlock private key profileID = '[YOUR PROFILE ID]' # Analytics profile ID.
- 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="Number" 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.