Google-sheets – Google Sheet Run Google Analytics Report from button

google analyticsgoogle sheets

I have a Google Sheet that is using the Google Analytics Add-on.

I have a sheet in the spreadsheet that pulls data from the Google Analytics results to present it to a customer.

On this page are the dates that the GA reports addon uses to fetch the data.

I would like a button on this page so that if the customer updates date fields, they can press the button and regenerate the reports. Is this possible? I'd prefer that they don't have to navigate the menu to run the report (or wait until the hour has expired on the scheduled report).

The addon itself does not provide a function to update the report. So the menu appears to be the only way to get the report to run. However, I imagine that the menu item triggers a javascript function – is it possible to identify the javascript call bound to the menu item, then trigger that same call using a button on the spreadsheet?

Best Answer

Short answer

Yes, the menu triggers a JavaScript function but it's no exposed to the users so they can't call it from a button.

Explanation

AFAIK the only way to interact with an add-on is through the exposed features like custom functions, custom menus or other elements added by the add-on.

When an add-on is open-source and the users are able to get the source code, they could use the source code instead of the add-on, then they could call the Google Apps Script function that updates the report by using a button.