In the world of digital advertising, one of the current trends is real time synchronization of advertising campaigns taking into account external factors that might influence the performance of those campaigns. Indeed, more and more advertisers are talking about synchronizing the launch of their campaigns with elements such as their TV spot schedule, the results of a sport event or even the weather.
In the meantime, many advertisers have always been taking some of their decisions based on a feeling and a judgement they acquired with experience. This way, many people think that because it’s snowing outside, people tend to spend more time on their connected device. So, there is an opportunity to increase their online presence to have a maximum reach of this audience. However, nothing proves that those feelings and judgements are correct.
Based on these two observations, we wanted to cross data about the interactions of users on a website with the weather conditions at the time of these interactions. The purpose behind this is, based on those data, to be able to answer the following question : “does the weather influence the way people interact and buy products on a website ?”The purpose of this first article is to explain how we managed to cross the website-performance data with the weather-related data. An upcoming article will then describe how we used the gathered knowledge to improve our campaigns performances.
Link a session on a website with the weather
In order to get weather data and send them to a web-analytics tool (in this case, Google Analytics), 3 elements are required:
- Geolocalization - allowing us to know where the user is located at the time (s)he is visiting the website.
- Open Weather API - in order to get meteorological data based on geolocalization information gathered beforehand.
- A DataLayer - allowing to link that weather information with sessions and send it to Google Analytics.
Gather geolocalization and weather data
First step is to know the weather at the time when each session occurred. To do so, we deploy through the Google Tag Manager (GTM), a custom script on each page of the website. A point of attention is that this script has to run once and only once per session so that data are not duplicated.
The first function of the script is to send a request to the geoplugin API to retrieve geographical coordinates (latitude and longitude) of the visitor at the time of his/her session on the website. Those data are stored in two variables (one variable ‘longitude’, and another variable ‘latitude’).
That’s when the second function of the script enters in the game, namely: call the Open Weather API, send it the two geolocalization variables, and receive in exchange meteorological data such as :
- State of the sky : sunny, cloudy, rainy, snowy, …
- Wind intensity
There are much more data available, but those are already enough to qualify the weather during the session of the user.
The third function of the script consists in storing those values in variables declared beforehand in the dataLayer.
Finally, the last function of the script consists of indicating that the meteorological data gathering event is done. We will call this state ‘weather_is_done’, we’ll come back to its usefulness in the next part.
Send weather data to Google Analytics
Each session is now linked with meteorological data from the place where the user browses the website at the time of his visit. Now all we have to do is to send those data to Google Analytics. Several elements are required to communicate our freshly gathered information.
First step consists in declaring some new ‘custom dimensions’ in Google Analytics. These dimensions will contain the meteorological data (temperature, humidity, …).
Since Google Analytics is ready to receive the new data, we can now send it through a tag created in Google Tag Manager. We therefore add in GTM a Google Analytics event tag that will gather data stored in the dataLayer by the script and send it to the specified Google Analytics property. The triggering of this tag is based on the event we have described above, namely ‘weather_is_done’.
So the circle comes back around and we can now easily cross meteorological data with website performance data such as transactions, conversion rate, time spent on the website, number of pages viewed, …
All we still have to do is to analyse trends in order to point out some weather scenarios that, according to data we’ve gathered and analysed, have a positive (or negative) impact on the performances.
As mentioned at the beginning of this paper, a second article will cover the way how the gathered data have been analysed to define weather scenarios and how we used the obtained insights to boost performances of our advertising campaigns.
Author: Julien De Visscher