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:

18 thoughts on “Weather & Sitelink script

  1. Arno Witte Reply

    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 Reply

    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?

  3. zortilo nrel Reply

    I’m still learning from you, but I’m improving myself. I certainly liked reading everything that is posted on your site.Keep the aarticles coming. I enjoyed it!

  4. Lisette Salk Reply

    Undeniably believe that which you stated. Your favorite reason appeared to be on the web the simplest thing to be aware of. I say to you, I definitely get annoyed while people consider worries that they just do not know about. You managed to hit the nail upon the top and defined out the whole thing without having side-effects , people can take a signal. Will likely be back to get more. Thanks

  5. turnpakjes zonder mouwen Reply

    Hi there! This post couldn’t be written any better! Reading through this post reminds me of my previous room mate! He always kept talking about this. I will forward this article to him. Pretty sure he will have a good read. Thank you for sharing!

  6. Mobiele car wash Reply

    Hi there, You have done an excellent job. I will certainly digg it and personally recommend to my friends. I am confident they will be benefited from this website.

  7. The Basterd Reply

    Great write-up, I am regular visitor of one’s site, maintain up the nice operate, and It’s going to be a regular visitor for a long time.

  8. vreyro linomit Reply

    What i do not realize is actually how you are no longer actually a lot more well-liked than you might be now. You are so intelligent. You know thus significantly in terms of this subject, produced me for my part believe it from a lot of varied angles. Its like men and women are not interested unless it is one thing to accomplish with Lady gaga! Your individual stuffs nice. At all times care for it up!

  9. Britsekorthaar Reply

    I am really impressed along with your writing talents and also with the format on your blog. Is that this a paid subject or did you customize it yourself? Either way stay up the excellent quality writing, it is rare to look a great weblog like this one nowadays..

  10. lace front wigs Reply

    Hi there, just became alert to your blog through Google, and found that it is really informative. I’m going to watch out for brussels. I’ll be grateful if you continue this in future. Lots of people will be benefited from your writing. Cheers!

Leave a Reply

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