Getting usage data from Smart Podcast Player in to Google Analytics

tl'dr: add an event to Google Analytics when someone hits play on Smart Podcast Player.

Pat Flynn's Smart Podcast Player (SPP) is the best player I've seen for Wordpress, and aside from an ultra rich experience like iTunes, probably the best game in town around in mid-2016.

So far it seems the product is focused on the player itself, but I suppose the SPP team is probably already working on some sort of analytics package. In the mean time I wanted a quick measure of how many people are actually using the player.

Technological support around podcasting is something I currently support for my clients in at best a cursory role, so I'm almost certainly uninformed here, but as far as I'm aware it seems the current state of affairs for analytics in the podcasting world is leaving lots of content creators with an underwhelming set of data.

In the interest of making the smallest of inroads on that front, and based on a call with a client this week where we wanted to understand just how many people are using the SPP player on their website, I threw together this little code snippet:


var sppPlayButton = document.querySelector('.spp-play')

if ( sppPlayButton != undefined ) {
  var hasHitPlay = false
  sppPlayButton.addEventListener('click', function(){ 
    if ( hasHitPlay === false) {
      hasHitPlay = true
      ga('send','event','SPP','User hit play on podcast player')
    }
  })
}

It's off the top of my head and I'll update as our initial data comes back, but here's the gist:

  1. Check if the player is on the page
  2. If it is, do some the following
    • create a variable tracking whether the user has hit play (hasHitPlay) already
    • send an event to Google Analytics
    • set hasHitPlay to true

What do you think? Is this the right approach? Feel free to shoot me your comments.