Google Tag Manager for WordPress can load the weather conditions around your site visitor using the OpenWeatherMap API. GTM4WP caches weather data for 1 hour to lower the need to access the API. You will also need to setup Geo data in order for weather data tracking to work. Depending on your website’s traffic, additional fees may apply at OpenWeatherMap and IP Stack.
You can place a cookie named
block_gtm4wp_geoip into the browser of your visitor to prevent the GeoIP and through that the Weather API usage to be disabled in the browser for that particular user. This is useful as the IP address of your site visitor will be shared with those 3rd party services and it is a good practice to get consent from the user to do that. If the user denies the consent, create the
block_gtm4wp_geoip cookie using any of the following values:
Once API keys have been set in GTM4WP plugin options (you can obtain the keys by registering for a free or paid plan at OpenWeatherMap and IP Stack), the following data layer variables will be available:
This will include the group of weather parameters: Rain, Snow, Extreme, Clear, etc.
This will include the exact weather condition within the group: Sky is clear, etc.
This will include a float number with the current temperature around the current visitor. To set whether to show this number in Celsius or Fahrenheit, go to the plugin settings and set the corresponding radio button.
This will include an integer number with the current pressure around the current visitor.
This will include a float number with the current wind speed around the current visitor.
This will include an integer number with the current wind direction in degrees around the current visitor.