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.
Configure the script
Mode and guardrails
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.
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.
Generated script
Configure the steps above, then click “Generate script.”
How to install & run it
- 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.
- Open Scripts.In Google Ads: Tools → Bulk actions → Scripts → the blue + button.
- Paste & authorize.Paste the generated code, click Authorize, and grant the script access to your account and external URLs (for the OpenWeather call).
- 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.
- 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.
- 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.
- Open Scripts.In Microsoft Advertising: Tools → Scripts → Create script.
- Paste & authorize.Paste the code and authorize it; Microsoft scripts use the same
AdsAppandUrlFetchAppservices, so it runs as-is. - Preview with dry-run on.Run once and review the log output before applying anything.
- Schedule hourly & go live.Turn dry-run off and schedule it to run every hour.
RGM Expert Says
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.
How the script works
Every run, the script loops your locations and calls the OpenWeather Current Weather Data endpoint for each one:
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:
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.
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.
Common questions
Does this work in both Google Ads and Microsoft Advertising?
AdsApp API and the UrlFetchApp service for the OpenWeather call, so the code is ready to paste with no changes.