Nic Cottrell
Nic Cottrell

Reputation: 9685

Does Google Drive Activity API expose view as an action?

I've managed to get the Google Drive API to run against a Google doc in my personal drive (of a Corporate paid account) using their example (after correcting for Python 2 syntax).

However, it shows only edit and comment as primary actions in that history, I don't see any actions saying just view.

Does that mean that there is no action recorded for document views? or that they are simply recorded as comment or something else, since the document URL always seems to redirect to .../edit even if I only grant View privileges.

Upvotes: 1

Views: 721

Answers (1)

Kristkun
Kristkun

Reputation: 5963

There is no view action detail in Drive Activity API.

edit or comment action detail cannot be used to get view action history.

I tried to view a document and get all its activity and there is no new record seen (either view, edit or comment).


If you want to get the view history of a document, here are some of your options:

  1. Use Drive API Files:get(), it will return a file resource which contains viewedByMe flag and viewedByMeTime datetime parameter.

It will only show the last time you viewed the file. If the file is shared, you cannot use this to get the recent datetime the file was viewed by other user.

  1. If you have an admin account, you can use activities.list in Admin SDK Reports API to access Drive audit logs which contains view log activities and other events. See Drive Audit Activity Events for a list of events available.

Sample activities.list Request Parameters:

userKey: all
applicationName: drive
eventName: view
filters: doc_id==13NgKy87BggedOXnmkymygTyEh0xxxxxxxx

NOTE:

  • If the file was viewed by a user outside your organization, the email address will not be available (User is anonymous)
  • Drive audit logs has a data retention time of 6 months. You can access Drive audit logs data this far back.

References:

Upvotes: 2

Related Questions