We, at Stape, have developed HTTP Lookup Variable for the server Google Tag Manager (sGTM). The variable is created to make HTTP requests. Thanks to HTTP requests, you can fetch data from external APIs and/or other web services that help enrich the data.
In this article, we will review a variable's use cases, learn how it works, and how to set it up in server GTM.
The HTTP Lookup Variable by Stape is beneficial in cases when you need to integrate real-time data from external sources into your GTM workflows. For example:
After configuring the HTTP Lookup Variable (check the section “How to set up HTTP Lookup Variable”) and adding it to the needed tag or another variable, GTM will send the HTTP request to the specified URL.
Since the HTTP Lookup Variable works with Promises (a JavaScript feature used for asynchronous operations), GTM will wait for the HTTP request to resolve (e.g., get a response) before proceeding.
If the request is successful, the variable will resolve with the data returned by the API.
2. Download the HTTP Lookup Variable from GitHub.
3. Open the “Templates” section in your server GTM container → find “Variable Templates” → click “New”.
4. Click three dots in the top right corner → click “Import” → select the template you downloaded from GitHub → click “Save”.
5. Go to the “Variables” → find the “User-Defined Variables” section → click “New” → choose “HTTP Lookup” variable type.
6. Configure variable
6.1 Add request method, you can choose from three options:
6.2 Add "Destination URL". It should be in the format "https://example.com," or you can choose the destination URL from the list of variables.
6.3 (Optional) Check the box:
7. (Optional) Add advanced variable settings.
7.1 Request Data - add properties and values you want to request.
7.2 Request Headers - here, you can add keys and values to the request.
7.3 Additional Options - add request timeout.
7.4 Logs Settings - choose whether the variable constantly logs to the console, logs during debug mode, or doesn’t log at all.
7.5 Format Value - select options to format the value that will be output by this variable.
HTTP Variable will be helpful for those who want to customize and enrich the data they retrieve since the HTTP requests retrieve data from external APIs or other web services. The setup process is simple, and the variable is easy to customize to your needs. If you’d like help, don’t hesitate to contact our support team.
Happy to hear that! Click Get help, fill-up the form, and we will send you a quote.