Weather Ad Bid Script Generator

Demand for umbrellas, AC units, tow trucks, hot soup and ski lift tickets moves with the sky. This builds a production-ready Google Ads or Microsoft Advertising script that reads live weather from the OpenWeather API and adjusts your budgets or bids by your exact rules — safely, hourly, and without drift.

Configure your locations, weather rules and safety caps below; the tool writes a complete, ready-to-paste automation script for your chosen platform. It calls the free OpenWeather Current Weather endpoint, evaluates your rules per location, and scales each location’s campaigns from a fixed base — so it never compounds. Built-in dry-run, modifier caps, and email alerts make it safe to ship. Copy it or download the .js and paste it straight into Google Ads or Microsoft Advertising — no normalization, no extra config.

Step 1 — Account & platform

Configure the script

Where the script will run.
For the script header & logs.
Free at openweathermap.org.

Step 2 — Lever & safety

Mode and guardrails

How weather moves spend.
Safety floor.
Safety ceiling.
Tags managed campaigns.
Change notifications.
Test before going live.

Step 3 — Locations

Your locations & base spend

Add each market you want to weather-tune. Find latitude/longitude by searching the city on OpenWeather or any maps tool. Campaign match targets the campaigns for that market (by name contains); base is the normal daily budget (or max CPC) the modifier multiplies from — this is what keeps the script from compounding.

Step 4 — Weather rules

Your bidding rules

Rules are evaluated top to bottom per location; the first match wins. If nothing matches, the modifier is 1.0 (base spend). Stack as many as you like — e.g. “temp > 30° → 1.4×” for a cold-drink brand, or “condition is Rain → 1.5×” for a roofing client.

Step 5 — Your script

Generated script

Configure the steps above, then click “Generate script.”

Walkthrough

How to install & run it

  1. Get a free OpenWeather key.Sign up at openweathermap.org, open API keys, copy your key into Step 1. New keys can take up to ~2 hours to activate.
  2. Open Scripts.In Google Ads: ToolsBulk actionsScripts → the blue + button.
  3. Paste & authorize.Paste the generated code, click Authorize, and grant the script access to your account and external URLs (for the OpenWeather call).
  4. Preview with dry-run on.Click Preview. Read the logs — they show exactly which budgets/bids would change and why. Nothing is applied while dry-run is on.
  5. Schedule hourly & go live.Set the lever to apply (dry-run off), Save, then schedule the script Hourly so spend tracks conditions through the day.
  1. Get a free OpenWeather key.Same key as above — paste it into Step 1 and pick Microsoft Advertising as the platform so the output matches its engine.
  2. Open Scripts.In Microsoft Advertising: ToolsScriptsCreate script.
  3. Paste & authorize.Paste the code and authorize it; Microsoft scripts use the same AdsApp and UrlFetchApp services, so it runs as-is.
  4. Preview with dry-run on.Run once and review the log output before applying anything.
  5. Schedule hourly & go live.Turn dry-run off and schedule it to run every hour.

From the desk

RGM Expert Says

Real Growth Matters — Paid media automationHow we use this tool with clients

Weather is one of the most under-used demand signals in paid search. For the right advertiser — HVAC, roofing, DTC beverages, apparel, tickets, lawn care, auto — a hot week or an incoming storm moves intent days before a bidding algorithm notices, because Smart Bidding learns from your conversion history, not the forecast. A weather script front-runs that, leaning spend into demand while it is forming instead of after it peaks.

The mistake we see in DIY weather scripts is compounding and over-reach: a script that multiplies the current budget every hour, with no caps, can quietly balloon spend 5× in a heat wave or zero it out in a drizzle. This generator is built the way we run it for clients — modifiers always apply to a fixed base you control, hard floor and ceiling caps, a managed label so every change is auditable, and a dry-run you must consciously turn off. On Smart Bidding we move budget, not bids, because tCPA/tROAS won’t let you set keyword CPCs; the budget is the honest lever.

Get the most from it by being specific and conservative first. Start with one or two markets, a single clear rule, a 0.7×–1.4× band, and a week of dry-run logs next to your conversion data before you widen the bands. The point isn’t to react to every cloud — it’s to capture the two or three weather states that genuinely change demand for your offer, and to let the rest sit at base.

Under the hood

How the script works

Every run, the script loops your locations and calls the OpenWeather Current Weather Data endpoint for each one:

GET api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&units={metric|imperial}&appid={key}

It reads weather[0].main (the condition), main.temp, wind.speed, and main.humidity, then evaluates your rules in order and takes the first match to get a modifier. The modifier is clamped to your min/max caps, then applied to that location’s base:

new budget = clamp( base × modifier , base × min , base × max )

Because it always multiplies the fixed base you entered — never the live value — running hourly can never compound. Campaigns are matched by your campaign-contains string and tagged with your managed label so changes are reversible. With dry-run on, every decision is written to the log and nothing is applied; with it off, budgets or ad group CPCs are updated and (optionally) a summary is emailed.

  • Budget mode — scales campaign.getBudget().setAmount(...); safe with Smart Bidding (tCPA/tROAS).
  • Manual CPC mode — scales each ad group’s max CPC; for manual-bidding campaigns only.
  • First-match rules — order matters; put your most specific/important rule first.
  • Caps — the clamp is the seatbelt; keep it tight until the logs earn your trust.

Uses the free OpenWeather Current Weather API (docs). Google Ads Scripts (reference) and Microsoft Advertising Scripts share the AdsApp/UrlFetchApp model. Non-compounding base model and safety design are RGM’s.

Best practices

Run it like a pro

A weather script is a force multiplier when it’s disciplined and a money pit when it isn’t. The teams who win with it treat it like any other experiment: start narrow, measure against base, and widen only what the data rewards. Keep dry-run on for at least a few days and read the logs beside your conversion volume — you’re looking for weather states where demand actually shifts, not for activity.

Mind a few realities. OpenWeather’s free tier is rate-limited (about 60 calls/minute), so a handful of locations per hourly run is comfortable; hundreds is not. Scripts run on the hour, not the minute, so this is for daily demand swings, not flash events. Keep your caps conservative on Smart Bidding — large, sudden budget jumps can knock campaigns back into the learning phase. And always leave the managed label on so you can find and revert every change the script ever made.

FAQ

Common questions

Does this work in both Google Ads and Microsoft Advertising?
Yes. Pick your platform and the generator tailors the output. Both engines use a near-identical AdsApp API and the UrlFetchApp service for the OpenWeather call, so the code is ready to paste with no changes.
Do I need a paid OpenWeather plan?
No — it uses the free Current Weather Data endpoint. You just need a free API key (allow up to ~2 hours for a new key to activate).
Will it compound budget changes if I run it hourly?
No. You set a fixed base per location and the modifier always applies to that base, never to the previous value, so hourly runs can’t drift.
Is it safe on Target CPA / Target ROAS campaigns?
Yes, in Budget mode. Smart Bidding won’t let a script set keyword CPCs, so it scales the daily budget instead — the correct weather lever. Use Manual CPC mode only on manual-bidding campaigns.
How do I test before it changes anything?
Leave Dry-run on. The script fetches weather and logs every change it would make without applying anything. Turn it off when the logs look right.
Which weather signals can I bid on?
Temperature, condition (Rain, Snow, Clear, Clouds, Thunderstorm, Drizzle, Mist), wind speed, and humidity — with as many stacked rules per location as you need.

Related on RGM

Keep learning

Related tools

Related tools