App Cloud Google Analytics
Google Analytics for App Cloud
- By default Google Analytics requires the support of cookies. In a published application the files are served from the file system which does not support cookies.
- We wanted to provide offline support so that we could track any events that may happen while not connected.
Because this is an application and not a website we are simply tracking events rather then page views. Documentation for Google Analytics event tracking can be found here.
- Copy the /lib/ga-appcloud.js file into your application and include it in your HTML files after the App Cloud SDK.
- If you do not already have a google analytics account, create one here.
- After logging into your google analytics account, find your account ID in the top left hand corner. Should be a number that begins with "UA". Usually in the format of "UA-xxxxxx-x". At the top of the ga-appcloud.js replace the current ACCOUNT ID with your ID.
- (Optional) At the top of the ga-appcloud.js file replace the HOST_NAME value with your domain.
To trigger an event simply call the
bc.ga._trackEvent method and pass in your values. The
bc.ga._trackEvent takes the following parameters:
- Category - A string that is the category for this event. This allows you to ogranize your events in the google analytics dashboard by category.
- Action - A string that is the action for this event. Similar to the category, the google analytics dashboard allows you organize your events by action. This is typically what the event actually is, for example a play event, or a fullscreen event.
- Label - optional The label is a string that allows you to provide additional information about this event.
- Value - optional A number that will be passed to the event so that you do additional analysis in google analytics. For example an event for how long the user watched a video could be passed as value and then summarized in the google analytics dashboard.
A full example can be found in the example directory, but below is a quick example.
Thanks and credits
- Remy Sharp http://remysharp.com/2009/02/27/analytics-for-bookmarklets-injected-scripts/
- Eric Hynds
Visit GitHub for the latest source code.
Found a bug? Report it at the GitHub issue tracker
Anyone can join the Open Source @ Brightcove team. Dive right in and start responding to issues, answering forum questions or submitting code patches through our GitHub repository.