Skip to content
Iurie — home
All work
Case study9 min read

Turning analytics data into a daily IP blocklist for paid search

An online gaming operator was paying for ad clicks from customers it had already won and from bots that never would be. I built the pipeline that finds those IPs every morning and hands them to an AI agent that excludes them in Google Ads.

Role
Analytics engineer: data model, rules, pipeline, monitoring
Client
Multi-market online gaming operator
Period
5 markets evaluated, 4 live
Stack
GA4 · Server-side GTM · BigQuery · Cloud Functions · Cloud Scheduler · Slack · Google Ads API
Outcome
✦ Live in 4 markets; blocked repeat-customer IPs almost stopped clicking ads

1. The problem: two kinds of click nobody should pay for

Paid search budgets were leaking in two directions:

  • Existing customers kept finding the brand through acquisition ads, so the operator paid again for people it had already converted.
  • Automated traffic clicked ads, bounced within seconds, and never logged in or deposited.

The obvious fixes were off the table. The business had ruled out Customer Match and GA4 audience exclusions. That left one lever Google Ads still offers at campaign level: excluding IP addresses. It comes with hard limits:

  • Each campaign takes at most 500 exclusions.
  • IPv6 addresses can only be blocked one at a time.
  • Performance Max and video campaigns don't accept IP exclusions at all.

So the job was to find a small number of IP addresses that carry a large share of the waste, keep the list current every day, and avoid blocking anyone who might still become a customer.

2. How it works: a daily pipeline from first click to exclusion

Browsers don't reveal their IP address to analytics tags, so the first step was capturing it server-side and attaching it to every GA4 event. From there the pipeline runs unattended, with one row of configuration per market.

  1. Every event

    Capture the IP

    Server-side tagging adds the visitor's real IP to each GA4 event.
  2. 05:00

    Aggregate

    BigQuery rolls raw events up to one row per market, IP and day.
  3. Always current

    Apply the rules

    A view scores a rolling 14-day window and ranks candidates per market.
  4. 06:00

    Export and report

    A Cloud Function validates the list, writes JSON and posts a summary to Slack.
  5. After 06:00

    Reconcile in Google Ads

    An AI agent run by the paid media team adds new exclusions and removes expired ones.

The export always describes the full desired state for each market, not a diff. If an address drops off the list, the agent removes it from Google Ads, so exclusions expire on their own.

3. The rules: engagement separates bots from customers, not click volume

My first instinct, "many clicks means fraud", would have blocked the best customers first. The heaviest clicker in one market had 29 ad clicks in three days, and was a logged-in depositor with 3.4 hours of engagement. So the rules ended up keyed on what visitors did after clicking.

Repeat customer

has deposited before
AND clicks ≥ market minimum
AND at most 2 logged-in users on the IP

Excluded for 7 days after their last click, so a lapsed customer can be reached again.

Likely bot

never deposited
AND clicks ≥ market minimum
AND under 5 seconds of engagement per click
AND nobody ever logged in

Excluded for 14 days after their last click.

4. Where IP exclusion breaks: one IP is not always one person

An IP exclusion hides the ad from everyone behind that address. On home broadband that's a household. In a mobile-first market, where carriers route thousands of phones through a few shared gateways, it can be a whole neighbourhood. Before enabling the repeat-customer rule in a new market, I measured how many distinct devices sat behind each candidate IP.

2–3

devices per candidate IP

Market A, home broadband (average)

17.3

devices per candidate IP

Market B, mobile-first (average)

71

devices behind one address

The busiest single IP in Market B

What blocking repeat customers would have cost in Market B

Suppressing 484 converted customers would have hidden the ads from 7,317 people who had never logged in. That's about 15 prospects for every customer, and they're exactly the audience the ads exist to reach.

So I switched the repeat-customer rule off in Market B and kept the bot rule on. The bot rule survives shared networks because it requires that nobody ever logged in from the address, and a busy carrier gateway always has someone logging in. Market B's bot candidates averaged 5.3 devices per IP, compared with 17.3 for repeat-customer candidates.

And where it doesn't scale at all

The operator's largest market had around 9,700 ad clicks a day. Its 500 heaviest-clicking IPs, the most a campaign can exclude, accounted for just 2% of clicks. The waste was spread across about 330,000 light clickers. I recommended a real-time fraud service there instead of IP lists, and that market was left out.

5. Data traps: three bugs that returned plausible, wrong answers

None of these threw an error. Each produced numbers that looked reasonable until I checked them against something else.

IPv6 addresses were silently cut short

The IP was first stored as a GA4 user property, which caps values at 36 characters. A full IPv6 address can need 39. Every long address lost its tail, which turned distinct visitors into partial strings that matched nothing. The giveaway was that many stored values had exactly the same length. Moving the IP to an event parameter, which allows 100 characters, fixed it.

2001:0db8:85a3:0000:0000:8a2e:0370:7334   ← needed: 39 characters
2001:0db8:85a3:0000:0000:8a2e:0370:7      ← stored: 36 characters

"Missing" is not the same as zero

For visitors who never log in, GA4 records no deposit count at all, rather than 0. A filter for "no deposits" compared that empty value with zero, got "unknown", and dropped every anonymous visitor. Those are exactly the visitors the bot rule is looking for, so it returned nothing for weeks. Treating missing as zero restored it.

deposits = 0               -- unknown (NULL): visitor dropped
COALESCE(deposits, 0) = 0  -- true: visitor kept

GA4's click ID field missed most clicks

Counting ad clicks means counting Google click IDs. GA4's built-in field captured only some of them, and in one market capture collapsed after a tagging change. It also never records the privacy-preserving click IDs used on iOS, which were about a fifth of Market B's clicks. Reading the IDs straight from the landing-page URL recovered them.

Share of ad clicks GA4's click ID field captured

Show data table
marketCaptured
Market B69%
Market A32%
Market A, after the break3%

6. Results: blocked addresses stopped clicking; unblocked customers clicked more

Enforcement started partway through a six-week period in Market A, so some qualifying IPs were blocked and others qualified before blocking began. That gave a natural comparison between addresses that met the same rule, with and without an exclusion.

Change in ad clicks from qualifying IP addresses

Market A, six weeks of data with enforcement starting midway. The counts behind these percentages are in the single and double digits, so treat them as direction, not precision.
Show data table
groupChange in ad clicks
Bots, not blocked−55%
Bots, blocked−86%
Customers, not blocked+383%
Customers, blocked−71%

The +383% is the business case. Left alone, converted customers who click ads keep clicking them, and more often over time. Blocked, they almost stop. For bots, part of the drop is natural churn; net of that, blocking accounts for roughly 30 percentage points.

Two limits are worth stating. About 10% of blocked clicks came back from new addresses, and IPv6 users cycled through about 4.7 addresses in six days, compared with 1.5 for IPv4. IP exclusion trims waste; it doesn't seal it off.

7. Keeping it honest: three silent failures, and the check each one left behind

A blocklist that quietly goes stale still looks like a blocklist. Every one of these failures reported success.

August: the schedule that was never saved (found after 10 days)

The daily load had been created in the console, which silently failed to save it. Data went stale while the export kept reporting success with a shrinking list.

Now: the schedule is created from the command line and verified after every change, and a staleness check warns in Slack.

October: a tagging change switched off a rule (found after a week)

A site re-instrumentation added about 100 new events, raising the typical number of event types per IP from about 2 to 10. A bot-rule condition that capped event types could no longer match anything.

Now: that condition is gone, because engagement time doesn't depend on event names. A market with no candidates is reported explicitly instead of vanishing from the export.

November: a late export nearly left a permanent hole (found in 2 days)

Google delivered one day of analytics data more than a day late. The load read an empty source, wrote nothing, reported success, and moved on to the next day. A check on the latest date couldn't see a gap in the middle.

Now: the load heals itself. Each run backfills any missing day from the past five and fails loudly if today's target is absent, and the export flags every gap in the 14-day window.

8. Scaling to new markets: a repeatable path from "maybe" to live

Adding two more European markets turned the lessons above into a checklist. Each new market runs in shadow mode first: fully computed and visible in a mirror view, but invisible to the agent until it passes.

  1. Confirm IP capture. Nearly 100% of events carry a full-length IP.
  2. Load and verify. Add the market to the daily load and check the change actually deployed.
  3. Backfill and shadow. Load history, then compute candidates with enforcement off.
  4. Check devices per IP. Compare against a market that's already live.
  5. Brief the agent. The agent gets updated instructions before the market appears.
  6. Switch on and watch. Dry run first, then daily reports for the first week.
MarketRepeat-customer candidatesMedian devices per IPIPs with 5+ devicesDecision
Market A (live baseline)1111Both rules
Market C3413Both rules
Market D2315Both rules
Market B–17.3 (average)–Bot rule only

Markets C and D went live with about 40 and 30 excluded addresses on day one, well inside the 500-per-campaign limit.

9. What I'd do next

  • A permanent holdout. Every qualifying IP is blocked, so the effect can only be measured through accidents of timing. Hashing each address and leaving a fixed 30% unblocked would give a clean control group for good.
  • Brand campaigns. Excluding repeat customers from brand ads could save the most, but if competitors bid on the brand name, it can hand them the top slot. The right answer differs by market and should come from auction data, not a blanket rule.
  • A device cap. Even the bot rule picks up shared addresses in mobile-first markets. A ceiling on devices per IP, applied everywhere, would trade a little coverage for a lot less collateral.

The client, brands, markets and accounts are anonymised; market letters are consistent throughout. Figures come from the project.

  • #bigquery
  • #server-side-gtm
  • #google-ads
  • #automation
  • #fraud

Keep reading