Export Google Fit Daily Steps, Weight and Distance to a Google Sheet

Updated on Friday, December 29, 2023

Comments Page 8

Return to post.

Comments

Robert Ellison

Alex, try following the steps to revoke access and reset the script. If that doesn't help then post back.

Alex

I've followed all the steps and encountered no problems. I've authorised the sheet/script to pull my Google Fit data but when I do via the 'Get metrics' option in the menu on sheets, the script inputs a date under the 'Date' column but then there's no data under Steps, Weight or Distance.

Any ideas?

Looking in Google Fit, I can see the data is there, but it just isn't pulling.

Ian

Hey Robert--I was able to parse out date from datetime and also make the kg to lb conversion pretty easily. Getting data for day 0 is where i was stumped but your comment helped me fix that, as well. I appreciate your time, sir! Thanks again.

Robert Ellison

Hi, Glad to hear you're finding this useful.

As written the script pulls a full day of data so I'm not sure how useful the date vs time thing is. The date passed to the sheet has a set of properties like getHours() the should allow you to break it down in any way you need.

Converting weight is easy - before writing to the sheet add:

weight = weight * 2.205;

To get data for today change the two 1s to 0s in the call to getMetricsForDays() near the top of the script. The code will create a new row each time to call it so you could do this several times a day to get updates or you could delete the last row if it has the same date and then add the latest data depending on what you're trying to achieve.

idowens

Robert--to parrot many here, thank you for your hard work. I had one hiccup where I had to add my own email address as a 'test user' before I could authenticate but that could have been due to being signed in to two Google accounts within Chrome while I was working or another step I may not have followed to the letter. In no time at all, I worked through that and populated all my data.

I'm trying to accomplish a few things and am running into some issues. (1) I'd like to split DATETIME into two separate columns DATE and TIME [does the API allow for that?] (2) I'd like to return weight in lb as opposed to kg. In Sheets I can '=CONVERT(C2,"kg","lbm")' but was wondering if I can have the script return that without converting after the fact? (3) Finally, I'd like the script to grab the 'latest' measurements (i.e. day 0) so that if I weighed in this morning and then viewed the sheet at lunch I can see 'today's' numbers. I can easily change the trigger timing, but not sure how to adjust the script to just call yesterday vs. "latest".

Your awesome walk-through has allowed me to chart blood ketones (mmol/L) against daily weight from my WiFi enabled scale and have proved immensely helpful in achieving my health goals. Thank you again!

Shrek

Super convenient steps!!!

Thanks!!

Robert Ellison

Hi Jordan. I haven't seen that error but searching for it I see some suggestion that it could be due to V8 runtime. In the apps script see if you can disable that.

Jordan

I could have messed up somewhere, but I am getting an error saying "Property store is required".

Matt

This is brilliant - another thank you from me your hard work!

I'm also wanting to get resting heart rate so I'll keep checking back to see if one of you clever people work it out!

Robert Ellison

Francesco - I haven't tried to grab calories so I don't have any experience with how this data source behaves. Does other data look right? Also see this article.

Add Comment

All comments are moderated. Your email address is used to display a Gravatar and optionally for notification of new comments and to sign up for the newsletter.

Newsletter

Related

Average Server Response Time in Azure Metrics