Using Google Apps ScriptDB to track activity

In messing around with scriptDB, I covered some usages of scriptDB when it first came out, along with a method of siloing data to keep it organized. Here’s a usage that might be useful for tracking things – You could for example, implement this to track who is opening what workbook.

The Idea here is that you use your scriptDb (either one linked to a particular workbook, or a shared one you use for centralized to tracking) to record when certain events start and finish using Google Apps Script. Here’s an example of logging something that happened, and how long it took.


Because the data for tracking is siloed from any other data in your scriptDb, we can report on tracking activity easily like this, to a worksheet named ‘logger’


Similarily, clearing out all tracking data is straightforward.


Centralizing DB
In the example shown, I’m using a scriptDB associated with the current workbook – I’ve created a function to return my scriptDB.


Ideally, though, we might want to record all activity centrally. In this case we would pick a scriptDB to host the data   lets call it centralizedDb – and then create a script file in that project with the getPrivateDb() function, and create a library of that project using the manage versions command from the file menu. Then in each spreadsheet that you want to track things in, you would reference centralizedDb. Your code would now look like this and every spreadsheet would access the same scriptDb.


This tracker code can be found in the mcpher google apps script library which is publicly available here

Project Key :


Source code

Tracker code

You can find the code in the track module of the above library and in the gist below.

About brucemcp 223 Articles
I am a Google Developer Expert and decided to investigate Google Apps Script in my spare time. The more I investigated the more content I created so this site is extremely rich. Now, in 2019, a lot of things have disappeared or don’t work anymore due to Google having retired some stuff. I am however leaving things as is and where I came across some deprecated stuff, I have indicated it. I decided to write a book about it and to also create videos to teach developers who want to learn Google Apps Script. If you find the material contained in this site useful, you can support me by buying my books and or videos.

Be the first to comment

Leave a Reply

Your email address will not be published.


9 + 2 =