Stape
Search
Try for free

Weather variable for server Google Tag Manager

Updated
Sep 10, 2024
Published
Aug 23, 2024

Weather variable is a helpful tool for those who want to monitor the air temperature in their cities effectively and view the data in an analytics tool like Google Analytics 4. With Weather variable, you can set up the tracking via server Google Tag Manager, and in this article, we will guide you through the setup process.

How to set up Weather variable

  1. Create a server Google Tag Manager container

2. Go to your server GTM → click “Templates” → find “Variable Templates” → click “Search Gallery”.

Search Gallery in Variable Templates of GTM

 Find the “Weather” variable in the gallery and click “Add to workspace”.

Weather variable template in GTM gallery

OR

You can manually add it to sGTM. To do this, download the Weather Variable from GitHub. In “Variable Templates,” click “New” → “Import” and choose the variable you recently downloaded.

Import Weather Variable in Variable Templates of GTM

3. Go to the “Variables” → find the “User-Defined Variables” section → click “New” → choose “Weather” variable type.

Weather Variable type

4. Configure variable.

4.1 API key - you can get it from the OpenWeather service. The key is free, and you get it one register the account.

API key in OpenWeather

4.2 Select unit - here choose between Celcius and Fahrenheit.

4.3 Country code - provide a country and сity to get the temperature. If you use Stape or AppEngine Hosting for sGTM, then country and city will be detected automatically.

4.4 City - specify the city of which you want to monitor the air temperature.

4.5 Logs Settings - choose whether the variable constantly logs to the console, logs during debug mode, or doesn’t log at all.

4.6 (Optional) Format Value - select the options to format the value this variable will output. You have the following options:

  • Change Case to… (lowercase or uppercase)
  • Convert null to… (text or variable)
  • Convert undefined to… (text or variable)
  • Convert true to… (text or variable)
  • Convert false to… (text or variable)

Click “Save”.

Weather Variable setup

Conclusion

To sum up, the Weather variable is a powerful tool for accurately tracking air temperature in your city and analyzing the data using platforms like Google Analytics 4. You can effortlessly incorporate this data into your analytics processes by configuring tracking through server-side Google Tag Manager. We hope you find this setup process of Weather variable easy and straightforward. And if you need help, don’t hesitate to contact us.

Tagged with:gtm server

Try Stape for all things server-sideright now!