Strava, Slack, & WordPress Integration

A few years ago, I started working for a company called Dyn. There were a number of us who met every few days to go out for a run. In 2011 there were no more than 5 or 6 of us who ran at lunch. As the company grew, we were looking for ways to entice employees to remain active and fit. Part of this was a genuine belief that healthy people cost the company less in health care premiums, sick time, and had increased productivity.

There were a variety of efforts to try to track employee workouts and reward them for staying active. Then, one day the company subscribed to Slack as it’s corporate messaging platform. As a Strava user, I got to thinking, “Wouldn’t it be cool if employees not only created a Strava ‘club’ but have all activities post into a Slack channel to not only brag about what we did, but motivate each other and give kudos?”

Incidentally, I was also looking for a way to post my workouts easily on this website. I found a developer who created a WordPress plugin but quickly realized that his code was limited. It only worked for rides. I wanted the ability to post rides, runs, swims, walks, hikes, etc.

Looking at both of my projects (Slack and WordPress) I decided to re-write the developers code. I added additional conversions, ability to post PRs to WordPress, and expanded the code to allow for a significantly larger amount of Strava supported activities.

WordPress Plugin

As noted above, I re-wrote the WordPress plugin. Integrating with a post is simple. All one needs to do is enter a WordPress shortcode (with no spaces) such as:

[ strava id="684814915" ]

I added several items including a map (if it was part of the activity, tags for Strava “best efforts”, and several conversions for minutes per mile, pace per 100 yards, miles per hour, elevation etc. Overall this is really helpful for when I write race reports. An example of what this looks like is below.

Activity Details

View the Activity on Strava

Strava/Slack Integration

As I was modifying the code for the WordPress plugin, I realized that there was significant overlap for what would be an easy Slack integration. All I needed to do was set up a cron job to run every 15 minutes, poll the company Strava Club, and look for new activities. I compared the activity ID against that stored in a database I created. If my database did not have the activity yet, I’d process it, calculate several metrics including average speed/pace, insert it into the database, and then post into the Slack channel.

The Slack channel posting also pulled the avatar from Strava and provided a link directly to the activity. The end result was the company Strava club membership grew to roughly 10% of the employee base. There was also close to another 10% that joined the Slack channel to see what employees were up to. The Strava/Slack integration was a huge win, in my opinion, for motivating employees to go faster, farther, and more consistent with their activities. Many of these individuals also were or became Strava premium users.

Strava/Slack Integration
Strava/Slack Integration