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

Updated on Friday, April 28, 2023

Comments Page 10

Return to post.



Thanks, it is working as expected!

Just wanted to know if it is possible to fetch all the weights registered within a single day as well? Right now, only the daily average is fetched.


It's working.

Thank you Robert.

You are the best!

Robert Ellison

Sandy, sounds like you are nearly there. It's just returning one dataset now so change dataset[1] to dataset[0] in the remaining code that reads the weight value (two places to change).


I removed this from the script:


"dataTypeName": "com.google.step_count.delta",

"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"




"dataTypeName": "com.google.distance.delta",

"dataSourceId": "derived:com.google.distance.delta:com.google.android.gms:merge_distance_delta"


var steps = -1;

var distance = -1;

if (json.bucket[b].dataset[0].point.length > 0) {

steps = json.bucket[b].dataset[0].point[0].value[0].intVal;


if (json.bucket[b].dataset[2].point.length > 0) {

distance = json.bucket[b].dataset[2].point[0].value[0].fpVal;


steps == -1 ? ' ' : steps,


distance == -1 ? ' ' : distance".

Then i removed the column B and D on the spreadsheet, in both sheet "Metrics" and "History".

So now i have, on both sheets, "Date" in A1 and "Weight" in B1. Nothing else.

New error: "TypeError: Cannot read property 'point' of undefined".

What did I do wrong?

I'm really sorry if I did something wrong, I'm not used to do script :( .

thank you again

Robert Ellison

Sandy - delete the step and distance related lines from the script - you'd need to do this in the request, where the values are parsed and then finally where they are written to the spreadsheet.



thank you for the quick answer.

Yea, i have no distance in it.

I'm only interested to monitor my weight.

What should I do?

Thanks again

Robert Ellison

Hi Sandy, sorry that didn't work. I can think of two possibilities. The first is that you didn't authorize all the required scopes - seems unlikely but you could revoke access again and then check the consent screen carefully to make sure that all the scopes are granted. The other reason could be that your fit account doesn't have distance in it (that looks like the metric with the error). You could use the API Explorer to see which metrics are available. If I think of anything else I'll post back.


Hello Robert,

so I disconnected the script from google fit.

After on google sheets, from the google fit menu i did "reset settings", re authorized again from the link, authorization ok.

When I do "get metrics" i get the same error.

I really don't know what to do.

Could be that I'm running the script from my browser on my Pc?

Because on the google sheets app from my smartphone i have no menu, i did everything from my pc.

Am I missing something?

On my smartphone tho I installed google sheets app and cloud console.

Thank you for your patience

John Scheermeijer

Robert, Thanks for pointing me in the right direction.

I found the dataTypeName here: https://developers.google.com/fit/datatypes/activity#heart_points

It's com.google.heart_minutes right?

I'll study your script to figure out how dataSourceId is used for the other metrics.

Robert Ellison

John, heart points would be a great add. I'll look at it the next time I need to update the script. If you want to take a crack at it use the API Explorer linked above to find the dataTypeName and dataSourceId to add to the list of metrics being fetched.

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.

I Thought He Came With You is Robert Ellison's blog.



Average Server Response Time in Azure Metrics