Changing autodata source to Runkeeper

If you have less that 100 Strava Activities per month Zapier is free and seems to be working very efficiently (in fact better than my previous solution of Strava → Tapirik → Runkeeper → Beeminder) and it is always there after a max of 15 minutes, it is working better than the previous integration ever did.

If you don’t care about having your units in meters you can just use the basic Strava direct to Beeminder Zap, however if you prefer Km or Miles you’ll have to do it using the Code for Zapier.

Here is a quick tutorial.

Step 1: Set up a new Zap with Strava Beta and Code by Zapier as the trigger and action. Authorize your Strava Account with Zapier.

Step 2: Set up the filter for activities you want to go through to this goal. There is opportunity for great customisation here, below is a simple one to filter just for Rides (see Strave API Reference for Activities and scroll down to Activity Types for a full list.

Step 3: Set up the input fields exactly as below.

Step 4: Paste the following code in the code section, replacing the top 3 variables with your ones. (Note this is the first Javascript I have ever written, it probably breaks every rule there is and is stupidly done, but to works! :grinning: )

var auth_token = "authtoken"; //Get from https://www.beeminder.com/api/v1/auth_token.json .
var username = "username"; //Your Username
var goalname = "goalslug"; //The Goal Slug

var posturl = "https://www.beeminder.com/api/v1/users/" + username + "/goals/" + goalname + "/datapoints";
 
var distanceKM = parseFloat(input.distance) / 1000.0; //Change to a division factor of your choice e.g. 1609.34 for miles
var comment = input.name + " at " + input.time; //Change to a format of your choice.
 
var payload = { 
  "auth_token": auth_token,
  'value': parseFloat(distanceKM.toFixed(2)), //Cleaning up to 2 decimal places.
  'comment':  comment,
  'requestid': input.id, //Uses the Strava Activity ID as the Beeminder Unique ID to remove any possible chance of duplicate datapoints if you change the Strava activity after it has already Zapped.
};

fetch(posturl, {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify(payload)
  }).then(function(response) {
    return response.text();
  }).then(function(responsebody) {
    var output = {response: responsebody};
    callback(null, output);
  }).catch(function(error) {
    callback(error);
  });

Step 5: Test it with one of the sample activities Zapier provides (you can delete it in Beeminder afterwards by going to All Data).

Step 6: Save the Zap and activate it. Rinse and repeat for each goal and/or activity type you want.

Step 7: Get out there in the Winter’s air and do some exercise! :smile:

Hope that helps if you prefer to stick with direct Strava → Beeminder.

6 Likes