Get drive files stats (views/openings) | Google Drive API

Viewed 52

I've been searching the docs but I can't find anything.

The goal is to retrieve different stats from our files. Actually, we can retrieve almost everything we need, except for the document openings and document openings per user.

So here is the question: How can I retrieve document views of a drive document (a G Sheet to be more precise) ? Can I segment it by user ?

Thank you

1 Answers

I understand that your goals are the following one:

  • You want to retrieve document views
  • Of a particular document (and you know it's id)
  • Associated to a specific user

Please correct me if I get it wrong. If those are your goals, then you can use the Admin SDK as pointed out by Rubén in the comments. Now I am going to detail how you can make such a request easily.

You could use the method activities.list() to get a list with what you want. You only have to populate these four parameters:

Parameter Value Description
userKey The user's email Determine the user
applicationName drive Identifies the Google service
eventName view Designate the type of activity
filters doc_id=={MY DOCUMENT ID HERE} Filters by the document

That configuration will provide you with your desired data. Leave a comment below if you need help creating that request in your own environment.

Related