You can use functions in Google Sheets to create and modify Supermetrics queries.
Before you begin
Benefits
- Compared to normal data queries, using functions is faster.
- Query parameters can easily be modified — they’re right above the data, and not in the SupermetricsQueries tab.
- Whenever the query parameters are modified, the data will automatically be updated to reflect the changes.
Things to consider
- Google allows custom functions to run for only 30 seconds, so this method of fetching data is suitable only for quick queries. If the time limit is exceeded, the function will display "#ERROR".
- The query information won't be visible along with your normal queries on the SupermetricsQueries tab.
- The authentication information for accessing the data is stored as an authentication token right inside the query. Anyone that has access to this token can fetch data from the specified data source using the credentials of the user account you used for creating the query. Don’t share the token with anyone that shouldn't be able to get that data.
- The file where you use the function must have the SupermetricsQueries tab. The SupermetricsQueries tab is hidden by default. Open the Supermetrics sidebar to create the SupermetricsQueries tab in case the file doesn't have it.
Instructions
- Select an empty cell in a Sheets file.
- Open the Supermetrics sidebar.
- Set up your query date range, metrics, and dimensions.
- Under Data visuals, select Function or Function (+params).
- Click Get data.
The Function option inserts the function into the sheet along with the results. If you click the upper-left cell of the results in the table, you see the function.
The Function (+params) option inserts the updatable parameters into the sheet, and the function is available in the top-left cell of the results table.