Boost your performance using local weather data!

March 22, 2018 - Written by

** Update 2023 – GA4 **

The post consists in two different sections: in the first section the possible exploitations of weather data to improve marketing campaigns are explained, while in the second section you can see how to implement weather indicators via Google Analytics and Google Tag Manager. If you want to skip this fisrt part dealing with actionable data marketing and go directly to the technical stuff, please click here

Weather Based Marketing

As we all know the weather conditions – or “the weather” – have a noticeable impact on our mood, dietary habits, the choice of clothing, or day-to-day lifestyles until affecting the consumers’ purchase behaviours.

Possibly all industries may feel the effect of the weather and at the same time they can unlock huge business opportunities. As the weather affects all individuals, without distinctions, it is the perfect hook able to give rise to personalized targeting campaigns, infact:

  • The weather is the second factor, after the economy, in terms of its effective influence on the consumers
  • In the US local weather data are accounted for 3 trillion dollars of business in the private sector
  • 70% of the world’s population checks the weather forecast almost once a day (with the highest picks in UK, Scotland and Ireland)

And just to give you some sense of the potential impact on the users’ purchase behaviour look at the table below to see the weekly increases of sales when temperature increases or decreases of 1°, if compared to the average of the period.

Source: Profit of One Degree –

 And, of course, the temperature variation needs to be matched with the customers geolocation: 20°C in the north of Italy could encourage users to purchase new T-shirts, but the same temperature in the southern part of Italy could lead them to buy a light sweater or a longsleeve.

As an example let’s consider the test made by Sainsbury in the sale of barbecues. The company set up a promotional campaign to be delivered to Scottish customers when the temperature was rising 20°C; as a results they 3X their sales. To reach the same result in London, the temperature should reach or exceed 24°C.

The weather data can be of great use to better understand the customer’s mindframe, delivering timely and relevant messages, using a communicative style pretty close to the users’ mood.

ADA (American Dental Association) increases the advertising expenditure in connection with bad weather to deliver “negative messages” to emphatize and connect with the users’ feelings.

PizzaHut delivers a huge number of ads in connection with cold and rainy weather, when users are more likely to stay at home and take advantage of its food delivery service.

Temperature and Purchase Intent

Source: The Temperature Premium Effect, JCP 13

So effectively a research from Columbia Business School shows such a correlation between temperatures and purchase intent. Physical warmth, despite being product irrelevant, can shape consumer’s purchase decisions. The products not related with weather’s effects are purchased most frequently when the temperature reaches a range between 30°C and 33°C. Considering the aggregate data of the Google Analytics accounts we manage, we observe that purchases happen between 22°C and 27°C in Italy.

Weather Triggers

The Weather-Triggered Marketing can be based upon three Macro Categories according to the available data:

  • Historical Data
  • Real Time Data
  • Forecasting Data

Weather data is used thus to trigger ads and personalize marketing messages based on the audience’s local weather.

The Historical Data are often ignored – incorrectly – when it comes to targeting. Indeed, the analysis of the historical series is useful to uncover ciclicity or the impact of environmental factors on sales or on promotional campaigns.

The Real Time Data are the most commonly used and helpful to create web personalizations. Nevertheless, they must be exploited at best, as they capture the users’ mood in real time, that is in the moment they are engaging with the marketing campaign.

The Forcasting Data are useful to trigger a need/solution in the very short term and they are helpful to provide added-value to the current promotion.

Areas of application

Which activities can benefit from the application of a weather based data strategy?

I should say countless, but according to my personal experience with Analytics Boosters we applied them to create:

  • Pop Up
  • Push Messages
  • Email Marketing Campaigns
  • Targeting & Personalization

and also as an assist for Google AdWords ads.

Pop up 

That’s the simplest case: showing a pop up to users if they connect from a location where the temperature is higher o lower than a specified value.

Push Message (browser/ app)

As for the pop up, the trigger is a specific weather condition occurring in the users’ location, but the hardest thing is the copy of the message that should be catchy to attract and angage the user i the moment.

Email Marketing

The weather data should be used in this case as triggers and as a content hooks as well. The trigger works in the first/welcome mail in order to grab immediately the users’ attention. The content should change accordingly, based on the weather data of the previous 12-16 hours before the email is sent.

Targeting & Personalization

The users bucket for testing and the content to be delivered to the target can be based upon the weather conditions of the users’ location. The web personalization has a huge impact on the AOV (Average Order Value): delivering the best and immediate solution will surely influence the purchase intent.

According to a research from Hubspot 3 out of 4 users leave the site if the content is not in target or in topic.


Using custom script, the AdWords campaigns can be personalized according to the weather conditions. Find here more details

Implementation and Strategy

An interesting example of Weather Marketing is the case of Dove/Havas: via sensors inside the display located in Time Square, New York, different messages were delivered to people passing by. See below a video showing the campaign

Many are the information to consider when approaching Conversion Rate Optimization and Personalization strategies. To be featured on Time Square display involves a huge budget availability, but below you can find ideas for your project that led to a noticeable conversions uplift for our clients.

Industry: Fashion

Activity: Home Page Slider Personalization

Weather Trigger #1: Forecast Data up to 3 days

Weather Trigger #2: Real Time Data

The first trigger was useful to create a slider with two different promotions based on the weather forecast for the next 3 days. If the user connects from a location where the weather report calls for cloudy or rain and a temperature lower than 18°C, the slider shows warmer product like jackets, windbreakers and so on, together with the weather forecasts. The second trigger is helpful to show a pop up encouraging the users to subscribe to the newsletter. The contents should be inversely related to the weather: if bad weather is expected, the pop up will show copy and images related to sun, hot weather and sea.

Industry: Food & Beverage

Activity: Pop Up

Weather Trigger #1: Real Time Data

In this case different pop ups are delivered to different buckets of users to push the newsletter subscription or promoting the purchase of selected items. Based on the temperature of the users’ location, if it is equal or higher than 25°C, the pop up shows a message saying “Refresh with our beers” and a 5% discount is offered via the subscription form. If the weather is rainy, snowy or windy, the pop up includes an image of the products with a lit fireplace in the background and the user is invited to taste the promoted product.

Industry: Cosmetics

Activity: Website Personalization & Exit Pop Up

Weather Trigger #1: Real Time Data

For this specific client/project two set of weather data are useful: temperature/weather and UV index. By using the latter factor, in the case of a particularly high value, inside the banners as well as in the exit pop up, messages related to the UV skin care protection products were delivered.

Industry: Garden & Hobbies

Activity: Push Message

Weather Trigger #1: Historical Data

Analyzing the sales figures for products that are complementary to the inflatable pools, we noticed that many users purchased a cover afterwards. We found out that the purchase was related to temperature higher than 35°C for 3 consecutive days. Due to the weather, the pools tend to deflate and lose a good amount of water. Based on historical data, during the second day when the weather conditions occurred, a push message was delivered to users, promoting a discount on the cover or reminding them to…inflate the pool J


Many are the opportunities to create strategies and activities using weather based data, but they should enrich the information about the customer behaviour and not as single KPIs. As a result we could have a pretty clear picture of our user helping us to deliver contents and drive him to the conversion. If you are interested in find out more about using the weather data for your business contact us!

Add weather data to Google Analytics via GTM

Where data come from? How can I retrieve it? To send weather data to Google Analytics you need:

  • 4 tags into Google Tag Manager and 3 of them are Custom HTML
  • 4 GTM variables
  • 1 Google Analytics 4 event
  • 2 Google Analytics 4 event parameters
  • 1 OpenWeatherMap free account  

Tracking via Google Tag Manager

The basis for developing the tracking is a post from Simo Ahava published years ago, that I customized in many parts to meet new requirements: new weather APIs, free geolocation features, http vs https, etc. Let’s start with the first tag.

cHTML – Geolocal

Differently than Simo’s post, through this tag I retrieve the geolocation data without using a third party platform.

var locations=window.location.protocol;

if (locations != "https:"){
    jQuery.get("", function(response) {
    }, "jsonp");
    if ("geolocation" in navigator){ //check geolocation available
      //try to get user current location using getCurrentPosition() method
              //console.log("" \nLat : "+position.coords.latitude+" \nLang :"+ position.coords.longitude);
              var lati=position.coords.latitude;
              var longi=position.coords.longitude;
              var lat2 = lati.toFixed(2);
              var long2 = longi.toFixed(2)

The script above is set to retrieve user’s geolocation and works if the site is served over both http and https protocol. Inside the if statement this kind of information can be pulled out: through if we have http protocol and through the navigator function in the second case.  If the site is served over https a dialog box will be opened – at the first session – where the user is being asked to share with the browser his location data. If the site is served over http the dataLayer returns city and country and a custom event “location”, while if it is served over https returns latitude and longitude data (with a rounding off a maximum of two decimal numbers) and a custom event “mylocation”. You need to set up two new  dataLayer variables, for “lati” and “longi”. The trigger is all pages.

cHTML – Weather Real Https

Before setting up the following tag you have to open an account on OpenWeatherMap because you need the dedicated API Key.

      var wuAppId = 'VOSTRA API KEY';
      jQuery.get("" + {{Lati}} + "&lon=" + {{Longi}} + "&units=metric&appid=" + wuAppId, function(data) { 
             var tempi=data.main.temp;  

            'event': 'weatherDone',
            'weather': meteo,
            'temperature': tempi

In addition to the API Key the latitude and longitude values are passed and you get a custom event named “weatherDone” and two new variables: weather and temperature, which reflect obviously the weather conditions. You may want to add other information such as the UV index or the maximum and minimun temperature simply pulling out the corresponding data from the json. The tag above must be fired when “mylocation” custom eventi is set.

cHTML – Weather Real Http

The tag below, very similar to the previuos, is for sites served over http. The procedure is the same set above, but the tag should be triggered when the custom event “location” occurs.

      var wuAppId = 'YOUR API KEY';
      jQuery.get("" + {{Lati}} + "," + {{Longi}} + "&units=metric&appid=" + wuAppId, function(data) { 
             var tempi=data.main.temp;  

            'event': 'weatherDone',
            'weather': meteo,
            'temperature': tempi

Google Analytics 4 event and parameters

If you’ve got that far now you have to send GTM data to Google Analytics 4, by setting an event, named “weather_condition”. Inside this event you must include two parameters, aka custom dimensions, related to weather and temperature and the tag should be fired only in the presence of the custom event “weatherDone” (that is the same for the two tags).

Weather Tracking GA4

The result inside Google Analytics is something like the following:

Hope this helps to improve your marketing campaign. Let’s keep in touch if you are interested in exploiting all the information above for your business, adopting a data driven approach.

Comments 12 Replies to “Boost your performance using local weather data!”
  1. Hi guys,

    Can you send me the code too please to my email? Its Please do send it in the same order as you have above so that I can follow it step by step.

    Also, are the above steps the complete steps or is there anything else we need to add for this to work?


  2. Hi guys, very nice blog post, thank you very much! Short question: it’s quite hard to read the code. Is it possible to get the code as text, so that I can copy & paste that to try it myself? WOuld be really appreciated 🙂

    Thank you!

    Best regards,

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Analytics Boosters

    Vicolo Buranelli, 2
    31100 Treviso

  • Analytics Boosters
    United Kingdom

    41 Devonshire Street
    W1G 7AJ
    United Kingdom

  • Analytics Boosters
    United States

    80 S.W. 8th Street
    33130 - Miami
    United States of America


Contact us