Hacks

Sending Strava data to Google Analytics using Zapier and the Measurement Protcol

In 2019 I bought a gravel bike and started enjoying some time in outdoors again away from computer screens. As a data professional & geek I started collecting my stats using Strava. However, a lot of the data I was actually interested in was sitting fairly deep in the app¬† and visualisations were somewhat off for what I needed. Strava has an API but I’m not a programmer at heart. So I wondered:

“How could I extract & visualise the data in a way that made sense to me in a very automated way?”

Step 1 – Welcome to Zapier

In 2018 I wrote a guide on how to track Spotify saves using Google Analytics  & the Measurement Protocol. I later translated that dataset into a Data Studio visualisation. Knowing that these type of things were possible I decided to give it a try. This guide allows you to reproduce it.

Zapier logo

Unfortunately¬†IFTTT¬†does not provide any Strava integrations. For that reason I decided to explore some other options. We’ll be using Zapier.¬†Zapier¬†is the equivalent of If This Then That or¬†IFTTT.¬†Zapier¬†allows for some more complex actions & sequences. Moreover, the offer a complimentary and slightly more business focused integration of apps in comparison to¬†IFTTT.¬†

Here’s how Zapier describes Zapier;

Zapier¬†is the glue that connects more than 1,000 web apps. Zaps are Workflows that connect your apps, so they can work together. Zaps Start with a Trigger‚ÄĒan event in one of your apps that kicks off your workflow. Zaps Automate Tasks in the background, so you can focus on more important work.

Create an account and you’re good to go.

Step 2 – Connect Strava

  1. Select Strava as an application.
  2. Secondly you’ll have to choose your trigger event.
Zapier - Strava configuration

Step 3 – Connect Google Analytics

  1. Create a measurement in Google Analytics.
  2. Select the choose action event drop down and select “create a measurement”.
Zapier - Google analytics setup
  1. Start preparing the Google Analytics Event measurement template. As soon as you select an input field you’ll be present with a vast selection of values coming directly from¬†Strava¬†that can be used as input for the Google Analytics measurement template.
Zapier - Google Analytics Setup with Strava input details
  1. Configure the event itself. Below you can find the current setup I’m using. As we’ll be using the default Google Analytics Event tracking template we’re limited to a selection of fields. Initially the objective was for Google Analytics to be able to automatically calculate the total distance ridden. However, the only field capable of taking care of that is the the “event value” element. The problem here is that Google Analytics expects integer values. Not all values provided by Strava are actually integers. Trying to push through floats will result in the Zap not being executed. This is illustrated by the screenshot on the right hand side. In order to bypass that limitation a 2-step Zap could be created but note that this requires a paying Zapier account.
    In order to get data shipped either way without hitting this limitation we’re storing the distance value as an Event Action. We’ll be transforming this value later during the Data Studio setup. For a full view on each element within the Measurement Protocol you can consult the Measurement Protocol reference guide.
Zapier - Google Analytics Setup with Strava event details
Zapier - Google Analytics Zap problem

Note РThis is essentially Zapier using the Measurement Protocol. Typically this would be executed through a webhook (which is actually upon which this integration is built upon). However, using raw webhooks requires an upgraded Zapier account.

Step 4 - Visualising data

  1. Create a Data Studio data source.
  2. Select “add field” & recreate the following setup in order to express the distance in KM’s.
Data Studio - Data Source distance in KM
  1. Repeat this step for the “event label” but divide by 60 to expres time in hours.
  2. You are now ready to visualise your data.