Setting up a Weather Feed

In this article, you will learn how to set up a data feed which can then be used to activate or pause campaigns. 

A quick example: let's say you sell sports clothes and you have a campaign for ice-skating clothes. You could set-up a data feed for temperature which activates your campaign when the temperature reaches below 0 and pauses above 0. This article will explain you how to set up a data feed for temperature in Amsterdam, but it can be used for every city.

Step 1

The first step is to create an account on https://home.openweathermap.org/users/sign_up. This website is free for basic usage such as the current weather. After creating an account you will get a pop-up asking for the purpose of your usage. Most probably you will use it for advertising so you can select Advertising. Following the registration, you should have received an e-mail which holds your API key. This key is your personal code for your data feeds.

 

Step 2

The following step you need to take is to create a URL which you can use on The Next Ad. A basic weather URL will look as following: https://api.openweathermap.org/data/2.5/weather?id=2759794&units=metric&appid=2e4d31e8dc1336d6ab75cc5609b40cff

However, you can/need to change this URL so that you can use it for your cause. The beginning of the URL should be the same, but you have 3 custom set-ups you can change.

  1. The City ID, in the middle of the URL it says =2759794, which is a city forecast for Amsterdam. If you want to create a data feed for a different city you need to find the correct City ID and change it within the URL. In this link https://openweathermap.org/city/, you can look up a city and find the City ID. The following image shows Utrecht, and you can see the code for that city above in the link.
  2. You can change the units in which it is measured. The shown link already uses metric but make sure you use it in the URL as well to get the correct measurements.
  3. The link also has an appId, which is your own API Key which you received when registering the account. You need to paste your key in the URL and remove the key as shown in the link. You remove everything after 'appid=' and place your key there.

After these steps you have your API URL which you can use in The Next Ad. If you then want to have another feed for a different city you only need to change the city ID.

Step 3

Go to the Control Panel in the left-hand side menu of The Next Ad. Select Data Feed, next select Add data feed. Fill in a name and paste the whole URL into the URL field. For name, select a name that makes sense, in this case Amsterdam - Temperature

Step 4

Then, add an attribute by clinking on the Add attribute button. Use ID as name and the type should be number. Following that, check the checkbox Use as id for the ID attribute.

Step 5

Add a new attribute by clinking on the Add attribute button underneath your existing attribute. Give the attribute a name—we advise you to name it Temperature. Choose the attribute Temp, which can be found under main. Next, select the type Number

Here you can choose to user other measurements such as rain or snow as well. To choose a different measurement than Temperature such as Rain and for the type go for number again. Following that you choose the attribute Rain > Rain 1h or Rain 3h. 

Important Note:

Different cities use different weather stations and therefore it is possible that your city does not use a specific attribute within the feed. Thus It is advisable to occasionally check your data feeds on rainy days. This way you can find the attribute used within the feed which can then be used in setting up the feed within The Next Ad. 

To see which attributes are supported you open the feed (https://api.openweathermap.org/data/2.5/weather?id=2759794&units=metric&appid=dff4d7ba06cec0877f33eb2800955968). This is the feed from Utrecht and if you open it and it indeed has been raining in the past hour, you can find the Rain 1h attribute.

Step 6

After these steps, your data feed has been created and you can use it in a campaign.

 Step 7

Add a new rule to your campaign. Give your rule a name, for example 'Pause When temperature above 0 – Amsterdam'. Select your action, for example Pause Campaign. Next, select the data feed that you have added in step 3. Then, select when you want us to take action. For example When Temperature is Greater than 0.

 

Step 8

Add another new rule to your campaign. Give your rule a name, for example Activate when temp below 0 - Amsterdam. Select your action, for example Activate Campaign. Next, select the data feed that you have added in step 3. Then, select when you want us to take action. For example When Temperature is Less than and then fill in the temperature ‘0’ in this case.

 

Step 9

Go back to The Next Ad and set up your new rules. Click on Select a rule and add your rules. For example Pause when temp above 0 Amsterdam and Activate when temp below 0 Amsterdam. This will make sure your rule will be activated, paused and activated again whenever you want to. Last but not least, please select an attribute to check, select the ID attribute, and fill in the city code 2759794 in the next field (Which value should it have).

Congratulations, that's it! You have set up your weather feed and can start using campaigns that will be activated or paused based on weather conditions.

 

If there are still any questions regarding the Weather feed, do not hesitate to contact us!