The Google Sheets Tag for Google Tag Manager Server-Side allows you to send data directly from your server container to a specified Google Sheet. This enables you to log events, capture form submissions, or store any other data for analysis and reporting.
The tag supports two primary actions:
- Append data: Appends a new row with your specified data to the end of the selected range.
- Update data: Overwrites the data in a specific cell or range of cells.
How to use the Google Sheets Tag
- Add the Google Sheets Tag to your server container in GTM.
- Select the Action Type (
Append dataorUpdate data). - Provide the Spreadsheet URL of the Google Sheet you want to write to.
- (Optional) Specify the Sheet Name (e.g.,
Sheet1). If omitted, the first visible sheet will be used. - Select the Dimension (
RoworColumn). This determines whether the data is added horizontally (row) or vertically (column). - Specify the Range using A1 notation (e.g.,
A1:Z1). - (Optional) Enable Force new rows if you are appending data and want to ensure no overwrites if multiple operations are sent simultaneously and the ranges overlap.
- In the Data section, map the values you want to send to the sheet.
- Choose your Authentication method.
- Stape Google Connection – Uses a simplified setup via Stape’s connection.
- Own Google Credentials – Uses Application Default Credentials from your GCP environment.
- Add a trigger to fire the tag.
Parameters
Main Configuration
- Type: The action to perform.
- Append data: Appends data. The
Rangeparameter will be used to determine the last row of the table to append the new data. - Update data: Replaces data in the specified
Range.
- Append data: Appends data. The
- Dimension: Choose whether to insert values as a Row (horizontally) or as a Column (vertically) in the specified range.
- Note: For Append operations, selecting Column adds the data vertically into the next empty row of your range.
- Spreadsheet URL: The full URL of the target Google Spreadsheet.
- Sheet Name: The name of the specific sheet (tab) within the spreadsheet you want to write to. This is optional if the sheet name is included in the
Range. - Range: The A1 notation of the range to interact with. For example,
A1:D1for the first four columns of the first row. IfSheet Nameis not provided, you can specify it here (e.g.,'My Sheet'!A1:D1). - Force new rows: (Only for Append data) Enable this to force the spreadsheet to always write data in a new row. This prevents overwriting when multiple requests are sent simultaneously and ranges overlap.
Authentication Credentials
- Auth Type:
- Stape Google Connection: A simplified authentication method for Stape users. Requires enabling the Google Sheets Connection in your container settings. Learn more.
- Own Google Credentials: Uses Application Default Credentials from a Google Cloud Platform environment. This requires enabling the Google Sheets API on GCP, setting up a service account and granting it access to your Google Sheet. Learn more.
Data
- Data List: A table where you define the values to be sent. Each “Cell Value” you add will be placed in the next available cell of the range you defined, following the orientation set in Dimension (left to right for rows, top to bottom for columns).
Useful resources
- How to write data from server Google Tag Manager to Google Sheets
- How to set up the Stape Google Connection
- How to set up the Own Google Credentials
Open Source
The Google Sheets Tag for GTM Server-Side is developed and maintained by the Stape Team under the Apache 2.0 license.