Server Google Tag Manager can accept data from multiple sources like websites, CRMs, webhooks, etc. With the latest integration of Firestore and sGTM, we now have even more opportunities for data sources.
The Google Sheets Reader variable is a custom server Google Tag Manager variable created by Stape that allows reading data from Google Sheets. You can use it to pull values from single cells, full ranges, or two-column key-value pairs and enrich your server-side tracking setup.
We already have a blog post that explains how to write data from sGTM to Google Sheets. This article will show how to read data from Google Sheets and use it within a server Google Tag Manager container.
There are three types of actions that this variable can do:
The first use case that comes to mind is enriching sGTM data from Google Sheets. Let’s say there is a Google Sheets with User ID and user email. You can get a User ID in sGTM. With the help of Google Sheets Reader, you can enrich data with user email by finding the corresponding User ID in Google Sheet. It will help enhance user parameters, for example, for the Facebook Conversions API, increasing the match quality score of Facebook Conversions API events.
If you're a Stape user, setting up the Google Sheets Reader variable is simple. Stape handles Google authentication internally, so you don’t need to upload any service account keys manually.
Here’s what you need:
.tpl
file).The variable will now be able to fetch and return spreadsheet values, which you can use in other variables, tags, or enrichments inside sGTM.
If you're not using Stape's built-in authentication, you'll need to set up manual access to your Google Sheets using your own credentials. Here's how:
.tpl
file). Create a new variable using this template and choose the desired action type (Read Cell, Read Range, or Read Two Columns). Provide the spreadsheet URL and range, then select Stape Google Sheets Connection as the authentication method. Enter the spreadsheet URL and data range. For Authentication, choose Own Google Credentials.1. Follow one of the guides in the section above (for Stape users or for non-Stape users).
2. In sGTM, create a new Google Sheets Reader variable. In this guide, we will show how the Read Two Columns option works. After selecting this option, add the columns range. This method works only with two columns and returns an object that consists of these two columns. The first column will be used as a name, and the second column will be used as a corresponding value.
This is how our spreadsheet looks.
3. Add spreadsheet URL and range.
We’ve added this range A1:B4 to the Google Sheets Reader.
4. Test the Google Sheets Reader variable. In our case, it looks like this:
5. In sGTM, we know the product name and want to add product ID based on data from a spreadsheet. To do this, we will use the Object Property Extractor variable. In the Object, select your Google Sheets Reader variable that captures data from Google Sheets. In Property, we will choose the variable that records the product name.
6. Test Object Property Extractor. We’ve added a product named Beanie to cart, and the Object Property Extractor variable returned 1. It corresponds to the product ID for this product according to Google Sheets.
Integrating Google Sheets with Server Google Tag Manager opens up powerful opportunities to enrich your data using external sources like product IDs, user attributes, or custom mappings.
In this guide, we walked through how to use the Spreadsheet Reader variable to pull data from a Google Sheet and enhance your sGTM setup.
If you need help setting up server-side tracking, feel free to reach out - we’re happy to assist and make sure your implementation runs smoothly. Thanks for reading!
All it takes is a few simple questions. Click Get A Quote, fill-up the form, and we will send you a quote.
Comments