How we used the Measurement Protocol to track Spotify saves in Google Analytics | Publications

Unless you’re a real Google Analytics geek, you’ve probably already heard from the Measurement Protocol but haven’t seen any applications besides the coffee machine video. This video suggest you need to be McGyver in order to be able to work with the Measurement Protocol. Sure, you could be, but you don’t have to. In this article, I’ll show you how to connect Spotify with Google Analytics. As a music fanatic, it’s a fun experiment for me to conduct. I realise there’s no real business objective yet. My hope is however, that this experiment provides you with inspiration on how you could use the Measurement Protocol versus your needs.

Resources related to this procedure already exist. An example is this article. Our methodology is fairly similar but includes an updated version of the applets & music technology used.

Step 1 - The blueprint

What do we want to do? It’s fairly simple:

  1. Each time a track is saved in Spotify
  2. We send an event to Google Analytics that maps the artist and track combination

Of course, we could dive straight into API’s and do some wicked coding. Full disclosure, I can’t as I’m not a developer at heart. But that doesn’t have to stop us. We’ll use an intermediary technology called IF THIS THEN THAT or IFTTT. According to the web IFTTT “is a free web-based service to create chains of simple conditional statements, called applets.”

It lets you create an action (output) based on a particular trigger (input). And that’s exactly what we’ll need.

In short - It does exactly what it says it does: if action A happens, then execute action B.

Measurement Protocol to track our Spotify -  if this then that logo
In our case our “applet” will do the following:

If a track is saved on Spotify then send a webrequest to Google Analytics.

We’ll need to 2 building blocks for this.

  1. The first one is an existing Spotify action called “new saved track”.
    Measurement Protocol to track our Spotify new save track - If This Then That  - New saved track applet for Spotify
  2. The second is something called a “webhook” action service (formerly called “maker”).

The webhook action service basically allows you to hook up any input to anything that can handle a webrequest. In our case we’ll combine it with Spotify, but the possibilities are endless

Measurement Protocol to track our SpotifyMeasurement Protocol to track our Spotify Make a request- If This Then That  - Webhook action

This combination sets out the blueprint for our little experiment.

Step 2 - Build your hit!

The webhook action service will require a package or hit to be sent. The next step is to create the credentials that will allow us to send this package. We’ll do this using the Google Analytics Hit Builder.

After providing authorisation you’ll need to fill in the following elements:

Measurement Protocol to track our Spotify hit parameter details - Google’s hit builder for the measurement protocol

  1. Set V to 1 as it refers to the Measurement Protocol version you’ll be using. The only version available today is version 1.
  2. Set t to event.
  3. Fill in your UA-ID in the tid field.
  4. Click the refresh icon in the cid field. It will provide you with a user id which will allow GA to recognise you as a single user. Instead of the refresh button, you could actually pick a value of your choice as well.
  5. The field above this form “hit payload” will now be populated with a URL. Copy paste this URL.

Measurement Protocol to track our Spotify - Google’s hit builder for the measurement protocol - Hit validation step

Step 3 - Complete the IFTTT recipe

The last step is to complete the webhook credentials touched upon in “step 1 - The Blueprint”.

  1. Open up the Webhook configuration.
  2. Past the URL you created in “step 2 - Build your hit!” into the URL field.
  3. Enrich the URL with the actual event values. More information can be found here. In this case we only used the mandatory values:
    1. EC - Event category
    2. EA - Event action
    3. EL - Event label
  4. Set the method to GET.
  5. Set the content type to TEXT/PLAIN.
  6. Save the recipe

If This Then That - Full configuration to send Spotify saves to Google Analytics using the measurement protocol

The results in action

When listening to / discovery a new track on Spotify and hitting the “save” button, a package will be sent to GA. This works on all devices you’re logged into using the same Spotify account (as you authorised access). As such, it’s the equivalent of sending an event from a website, as you would usually do. However, in this case, the website has been replaced by a custom action, being a Spotify save.

Example of a Spotify save button on mobile

The desktop equivalent of this action is pressing the little hearth.

Example of a Spotify save button on desktop

An index of all saved songs becomes visible in Google Analytics under the “events” report.

Measurement Protocol to track our Spotify Googel analytics - Result in Google Analytics of saving Spotify saves using IFTTT & the measurement protocol



Happy music exploration & Measurement Protocol experimentation!



publication author Glenn Venderlinden
AUTHOR
Glenn Vanderlinden

| LinkedinThis email address is being protected from spambots. You need JavaScript enabled to view it.

Tags:

Get in touch

Semetis | 44 Rue des Palais, 1030 Brussels - Belgium

+32 (0)2 211 34 50

welcome@semetis.com

Connect with us