Weather & Sitelink script

Ever wanted to incorporate weather data in your campaigns? This script will help you to turn data into action. It switches sitelink A for sitelink B when it’s raining. You can configure a few variables to customize it to your needs, so take a look a get practical with data!

Why this script?

Recently I was in a sales meeting at my current client (Center Parcs). They manage several holiday parks in Europe where you can book a “cottage” (holiday home). In the meeting the Sales Director said:

One of the Unique Selling Points of Center Parcs is that we have an indoor swimming pool. So when you’re on holiday and it’s raining cats & dogs*, then you can still have fun with the kids!

And it’s true! All parks have a indoor swimming pool, shopping mall and a lot of indoor facilities. So that’s a great USP to communicate. However, the sitelink area is a much sought after piece of real estate in the Google SERP, so I’ve created a script thats swaps out one sitelink for another when is rains outside.

Open Weather API

The weather data in the script is provided by the Open Weather Map. You can use their API for free up to 60 calls per minute. I currently run the script every hour for one location, so this is sufficient. Signing up is easy & free. You can create your API-key after you’ve logged in on the API keys tab.

How to use?

The next step is to install the script in Google AdWords. You can find a “how to” here. Configure the script to your needs with te explanation below.

  • Open Weather API Key: fill in your key here
  • weatherLocation: fill in the location where you want to check the weather. Verify your location by doing a search on The correct naming and localization tag will be in the searchresults or on the result page
  • Conditions: the API returns different weather conditions. I use the weather summary to check if it’s raining in De Bilt. However, when it return “light rain”, then I want nothing to change. The conditions are listed here: link
  • Sitelinks: you can find the ID of a sitelink in the Shared Library > Business data > Main sitelink feed. Look up the sitelink you want to target (via filter) and look for the column “Item ID”.

Preview the script and check if everything works as expected. If yes, schedule it te run on the desired frequency and you’re done!


You can view the results in the Log and of course in Google ;):

Logs of AdWords weather script


70% of the script is copied from the Weather-based Campaign Management script from Google. So props for them. Go check out their page for some other practical uses of weather data.

*Cats & Dogs is not a Dutch phrase, so this is nog the exact wording he used. However, we do have a similar proverb but translated from Dutch to English that would be: “It’s raining with buckets from the sky” :).

I’m not a programmer by profession so the code is probably not DRY / SMART / CLEAN, etc, My apologies.


And of course the script itself:

2 thoughts on “Weather & Sitelink script

  1. Arno Witte

    Hi Martijn,

    Thanks for sharing, very simple but clever!

    Did the script result in additional clicks/sales? Would be very interested in an article about the results 🙂


  2. David

    This is a great script, really useful for your client a,d many others with similar strategies.

    I’ve been trying to modify it as i’d need something similar but it would be to add/remove Sitelinks based on Temperatures and not actual weather conditions. I’ve been trying to set up a code to run the script based on temperatures but I’m not all that comfortable with JS (limited understanding) so not been able to do it as of yet :-(.

    Is there a quick change to the code that can be done to run this based on temperature?

Comments are closed.