Search code examples
google-apps-scriptgoogle-analyticsgoogle-sheetsgoogle-drive-apigoogle-analytics-api

Using Google Sheets Menu with Google Apps Script


I am new to Google Apps Script and looking for some insight into a feature I would like to implement.

I am using the Google Analytics add-on inside of Google sheets to report on our site. I have already set up a script to send out daily reports, but currently still have to run the reports manually using the add-on. Is there a way I can access the add-on menu using Google Apps Script?

I'd like to add the functionality of clicking 'Run Reports' in the GA add-on menu before my daily email script. Any help would be greatly appreciated. Thanks!


Solution

  • I think what you mean is you're inside a sheet, and you want to be able to press Add-On->Add-on Name to run the report.

    You're not able to do this unless your script is a published Add-on available on the add on store for anyone to download. Given the restrictions Google currently has in place for that, it's unlikely you'll want to do that.

    Instead, you want to create a custom menu. An example found here. I'm not going to bother copy/pasting their sample, as I'd be leaving it as is.

    From the sounds of it though, you might prefer to create a time based trigger. The simplest way to do this is open your script, press 'Resources' -> Current projects triggers -> 'Click here to add one now'. This will allow you to set a time based trigger to run every day for example.