tvjs-google-analytics
v1.0.1
Published
This library provides Google Analytics support for Apple's tvOS TVMLKit JavaScript runtime. It uses the Google Analytics Measurement Protocol to provide a mobile SDK like API to track analytics events and screenviews within a tvOS Client/Server applicatio
Downloads
10
Readme
ES6 Google Analytics for Apple's tvOS TVMLKit JS Runtime
This library provides Google Analytics support for Apple's tvOS TVMLKit JavaScript runtime. It uses the Google Analytics Measurement Protocol to provide a mobile SDK like API to track analytics events and screenviews within the tvOS Client/Server application.
Example
First, initialize the library.
let ga = new GoogleAnalytics("YOUR_TRACKING_ID", "YOUR_APP_NAME");
Then, in your TVML documents onload
handler:
<document onload="ga.screenview('YOUR_SCREEN_NAME');">
...
</document>
And, in your event handlers:
function mySelectHandler(event) {
ga.event("YOUR_CATEGORY", "YOUR_ACTION");
}
Contributions
Contributions to support testing and additional event types are welcome.
Credits
Heavily inspired by Doug Richardson's prior art. https://github.com/drichardson/tvjs_google_analytics