We looked at how to create a json file on Google Drive containing the analysis of a google site in Analyzing site content with GAS. The script that creates that takes a whole lot of parameters, and we wouldn’t want to run that manually all the time. Ideally we would just want to run that thing from time to time. That’s where GAS triggers come in.

Setting up Timed Triggers

In the script editor under resources, there’s an option to set up triggers.

To set up a timed trigger just choose the function that you want to run, and select when and how often it should run.

Here, I’m executing a function called ‘timed’ every night around midnight.

Setting up the parameters

I want to call my doGet(e) function, just as if I’d called it from a browser. However, I still need to pass the url parameters. Here’s how.

function timed() {
 // this is a trigger im running every day
  var e = getDefaultE();
  e.source= "site";

It’s straightforward to simulate how GAS converts parameters as arguments, and now this will run every night, refreshing the site analysis data. See Analyzing site content with GAS for the details of what doGet() is doing in this example.

Find out more about Gas and sites here