Notes and anecdotes

Techstuff rambling

Access Google Analytics API with OAuth token

Notes on adding a Google Service worker that enables you to query Google Analytics with an access token.

Track custom events with google analytics

Requirements: You have an existing google analytics account You have a webpage to track events with How: Edit: If you’re onĀ ES6 with webpack or similar, checkout this Github Gist instead. 1. You include google analytics in your page (function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,’script’,’//’,’ga’); // Replace UA-XXXXXXX-X with your google analytics user key ga(‘create’, ‘UA-XXXXXXX-X’, ‘’);…

Continue Reading