Cédric Brun bio photo

Cédric Brun

Build open-source technologies to enable mission critical tools for complex domains.

Email Twitter Google+ Github

reveal-ga

reveal-ga

A plugin for Reveal.js to add Google Universal Analytics tracking to your presentations.

Reveal.js provides a number of events that we can listen for, and this package will send those events to Google Analytics for tracking.

Installation

  1. Install the plugin via npm:
    $ npm install --save reveal-ga
    
  2. Obtain a Profile ID from Google Analytics; this should look something like UA-XXXXXXXX-X.
  3. Define a gaPropertyID variable in your presentation file before Reveal.initialize():

    <script>
     var gaPropertyID = 'UA-XXXXXXXX-X';
     Reveal.initialize({
         // ...
     });
    </script>
    

What is tracked?

After setting up the package according to the instructions above, Google Analytics should pick up on the following actions:

  • Any time the active slide is changed
  • Slide overview (triggered by the ESC key) shown or hidden

Debugging

If you want to see what information is being sent, drop the following somewhere in your presentation to get debug statements output to the console:

window.addEventListener('reveal-ga', function (ev) {
  console.log('New Reveal GA event:', ev.detail);
});

Every time a new event is sent to Google Analytics a corresponding custom event is also sent to the window object as reveal-ga.