The Google Sheets Reader Variable for Google Tag Manager Server-Side allows you to read data from a Google Sheet and use it within your server container. This is useful for enriching data, creating lookup tables, or managing settings dynamically.
The variable supports three action types:
- Read Cell: Fetches the value from a single cell.
- Read Range: Fetches all values from a specified range as a two-dimensional array.
- Read Two Columns: Fetches data from two adjacent columns and returns it as a key-value object.
-
Add the Google Sheets Reader variable to your server container in GTM.
-
Select the Action Type:
Read Cell
,Read Range
, orRead Two Columns
. -
Provide the Spreadsheet URL of the Google Sheet you want to read from.
-
(Optional) Provide a Sheet Name (e.g.,
Sheet1
). If not set, the first visible sheet is used. -
Specify the Cell or Range using A1 notation (e.g.
A1
,B2:C10
). -
Choose your Authentication method.
- Stape Google Connection – Uses a simplified setup via Stape's connection. Learn more.
- Own Google Credentials – Uses Application Default Credentials from your GCP environment. Learn more.
-
Use the variable in your tags, triggers, or other variables within the server container.
- Type: The read operation to perform.
- Read Cell: Returns the value of a single cell as a string.
- Read Range: Returns a range of cells as a 2D array (an array of rows, where each row is an array of cell values).
- Read Two Columns: Takes a two-column range and returns an object, using the first column for keys and the second for values.
- Spreadsheet URL: The full URL of the target Google Spreadsheet.
- Sheet Name: The name of the specific sheet (tab) to read from. This is optional if the sheet name is included in the Cell/Range parameter.
- Cell: (For "Read Cell" type) The cell to read from, using A1 notation (e.g.,
B4
). - Range: (For "Read Range" and "Read Two Columns" types) The range of cells to read, using A1 notation (e.g.,
A1:D10
).
- Auth Type:
- Stape Google Connection: A simplified authentication method for Stape users. Requires enabling the Google Sheets Connection in your container settings.
- 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.
- How to read data from Google Sheets in server Google Tag Manager
- How to set up the Stape Google Connection
- How to set up the Own Google Credentials
The Google Sheets Reader Variable for GTM Server-Side is developed and maintained by the Stape Team under the Apache 2.0 license.