FitBit + Google Spreadsheets = Awesome

This post and instructions are no longer up to date. For a current how-to please visit the updated post

On February 11th FitBit released their API into the wild and let developers get to work. Since then there have been some very neat integrations. One of the best uses of the API it the open source script that enables users to download their data into google spreadsheets. Developed by John McLaughlin, this script gives everyone the ability to get their historical data from FitBit and play with visualizations and analytics. Even someone without any programming experience can start creating very neat dynamic charts and graphs in under 30 minutes. For example I created the the following charts in just a few minutes (click images for interactive versions):

Daily Step Count:

If you already have a FitBit you might be wondering how to actually implement John’s script to grab your own data and start making fun charts and graphs. It takes about 15 minutes from start to finish to set up your FitBit developer account and then set up the script in Google Docs. The step-by-step process is outlined after the jump.

How to set up FitBit & Google Spreadsheets integration:

Importing FitBit data into Google Spreadsheets from Ernesto Ramirez on Vimeo.

  1. Download the FitBit For Google Apps Script from Github
    • Open the Github repository for the script
    • Click the downloads button and save the .zip file to your computer.
    • Unzip the folder and open the fitbit.js file in your text editor of choice.
  2. Modify the script to specify specific variables and the time period if desired.
    • Find the period variable (var period) on line 11. This variable can be changed to ask FitBit for data for a specific period of time. You can change it to 1 day, 7 days, 30 days, 1 week, 1 month, 3 months, 6 months, 1 year, or maximum allowable (since system launch).
    • Find the activities variable (var activities) on line 51. Here you can adjust what variables are imported into your Google Spreadsheet. You will already see all of the available activity, sleep, and food (calories in) variables included in the script.
    • If you have paired a Withings scale with your FitBit account or are tracking your weight using another method you can include weight data by including the following calls in the var activities function: weight: “body/weight”, BMI: “body/bmi”, body fat %: “body/fat”.
  3. Set up your FitBit Developer account and register an app.
    • Go to and sign in using your FitBit credentials.
    • Click on the “Register an App” at the top right corner of the page.
    • Fill in you application information. You can call it what you want. Make sure to click “Browser” for the Application Type and “Read Only” for the Default Access type fields.
    • Read the terms of service and if you agree check the box and click “Register”
  4. Copy the API keys
    • Copy the Consumer Key
    • Copy the Consumer Secret
    • You can save these to a text file, but they are also available anytime you return to by clicking on the “Manage my Apps” tab.
  5. Set up Google Spreadsheet Script
    • Create a new google spreadsheet.
    • Go to Tools->Script Editor
    • Replace the template with fitbit.js
    • Save the script and name it.
    • Run the “renderFitbitConfigurationDialog” function and click authorize to authorize the script.
    • Run the “renderFitbitConfigurationDialog” function again and enter your consumer key and secret.
    • Run the “Authorize” script — this will run through the oauth dance.
    • Enter your FitBit credentials.
    • Run the ‘refreshTimeSeries” function to get your data.
  6. Set up an automatic trigger to automatically update your spreadsheet with new data on a specific schedule.
    • Go to Tools->Script Editor
    • Go to the “Trigger” menu and select ‘current scripts triggers’
    • Add a new trigger that runs ‘refreshTimeSeries’ that is ‘time driven’ and choose an interval for the spreadsheet to update. I currently have mine set to ‘hour timer’ updating ‘hourly’ but feel free to choose something different.
    • Click save.

Once you’ve followed these steps you should be able to start using the “insert chart” or “insert gadget” methods to visualize your data. Feel free to share your visualizations in the comments. Also, if you have any questions feel free to contact me. Special thanks goes our to John McLaughlin for posting his opensource script to the FitBit Developers Google Group.

Happy Stepping!

This entry was posted in News and Pointers, Personal Projects and tagged , , , , . Bookmark the permalink.

25 Responses to FitBit + Google Spreadsheets = Awesome

  1. Marie says:

    Awesome, thanks for the script! I’ve been dying to use my Fitbit data but hadn’t gotten around to writing anything.

  2. Scott Rower says:

    this roooooocks! thank you :)

  3. Justin says:

    This is a geek’s dream come true. THANK YOU!

    (Note that if you want to change the script after you’ve run it, you have to follow these steps again:

    Run the “renderFitbitConfigurationDialog” function and click authorize to authorize the script.
    Run the “renderFitbitConfigurationDialog” function again and enter your consumer key and secret.
    Run the “Authorize” script — this will run through the oauth dance.
    Run the ‘refreshTimeSeries” function to get your data.)

  4. Justin says:

    One question: It looks like the timeInBed and other sleeping data only tell you about the time you were in bed at *night*, but it’s not counting other naps that you may take during the day. Is there a way I can put other non-night sleeping time in another column?

  5. Hi Justin,

    Thanks for your comments about re-running the functions when you make changes to the script. I had completely forgotten about that!

    In regards to sleep, they just updated the “GET SLEEP” data functions in their API documentation. You can find more info here:

    Hope this helps!

  6. Pingback: Tracking my activity & sleep with the Fitbit - MasterMaq's Blog

  7. FX says:

    That’s just AWESOME
    Great idea, very useful, and now my fitbit metrics are available for dataviz !!!

  8. Pingback: Fitbit Lab

  9. Pingback: Recap of Los Angeles QS Meetups | Quantified Self

  10. Benjamin says:

    Not sure if anyone else has had this problem, but I’m at the ‘Run the “Authorize” script’ step and after I’ve ‘allowed’ authorization I get the following message from Fitbit:

    ‘You have successfully authorized access to [my app's name]!
    Please return to [my app's name] and enter the following PIN when requested:

    I’m not clear where I’m supposed to enter that pin. When I try to run the ‘refreshTimeSeries’ it just asks me to authorize again. Any ideas? Thanks.

  11. Geek On Acid says:

    Great tutorial, thanks! Do you know if there is a way to upload your Fitbit journal entries? Seems like there is no resource path for journal entries in API documentation…

  12. Pingback: Code & form » FitBit, shame on you

  13. Pingback: Fitbit « kristopherjames

  14. Jynto says:

    Oh, this can’t be. I keep getting an error at the last part of step 5:
    TypeError: Cannot call method “getContentText” of undefined. (line 77)

    Line 77 is
    var o = Utilities.jsonParse(result.getContentText());

    Why oh why is this happening?

  15. ukfaruk says:

    TypeError: Cannot call method “getContentText” of undefined. (line 77)

    Same problem over here.

    Any insight?

  16. Tim Ramsdale says:


    I had the same error. If when you run the ‘renderFitbitConfigurationDialog’ function, you make sure you select one or multiple items in the Loggables list box, then this fixes the issue. I believe you get this error when you haven’t configured any variables to be dumped.

    Hope this helps

  17. Meghan says:

    I’m having problems running this script. I’m thinking changes were made between the time the video was posted, and I downloaded fitbit.js?
    I’m looking at the fitbit.js file I downloaded. It looks similar to the code in the video, but slightly different (different version)?
    I was able to make changes in the correc areas (I think), but was unable to continue past the “Configure Fitbit” dialog: prompted for consumer key & secret, but also prompts for resources and period, but is missing the “Authorize/Cancel” buttons.
    Any advice?

  18. Meghan says:

    Ahh, figured it out (had to enter period first, then go back up and select resources).

  19. jc wise says:

    is there an additional script that would break this up into minute increments or “real time” so I could graph daily activities?

  20. leandro says:

    is very difficult to add blood pressure in variables? i’m very interested in this data :-)

  21. Pingback: Frustfree way to get your fitbit data | Tech frust

  22. Pingback: Quantified Self: What am I tracking and why? | The Oakland Futurist

  23. Pingback: Fitbit Hacks for More Than Just Fitness

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.