Back to Blog
Guide·10 min read

Advanced Traffic Filtering in BATracker: Rules, Templates & Setup

Every wasted click costs money. BATracker's filtering engine gives you precise, real-time control over exactly which visitors reach your offers — and which get blocked, redirected, or flagged before they ever touch your budget. This is the complete technical setup guide.

1. How BATracker Filtering Works

Filtering in BATracker happens at the edge, before a visit is counted. Because BATracker runs on a modern Fastify (Node.js) tracker backed by ClickHouse and Redis, filter evaluation adds effectively nothing to BATracker's sub-10ms redirects. A filter is a simple, powerful equation: pick a filter type (what to inspect), an operator (how to compare), a value, and an action (what to do on a match).

Rules are evaluated in order and the first matching rule wins. If no rule matches, the click is allowed by default. That single principle — first match wins, no match means pass — is the mental model you need for everything below. Order your rules from most specific to most general, and put your explicit whitelists early.

The anatomy of a BATracker filter rule:

FILTER TYPE + OPERATOR + VALUE → ACTION

2. Every Filter Type (Grouped by Category)

BATracker exposes a rich set of dimensions to filter on — from geography and device to connection quality, bot status, and your own tracking fields. Here they are, grouped by category:

CategoryFilter TypesWhat It Inspects
GeographyCOUNTRY, CITY, REGIONVisitor location from GeoIP.
NetworkISP, DATACENTER, CONNECTION_TYPE, PROXY, IPISP name, datacenter/proxy flags, connection type, and IP address.
DeviceDEVICE / DEVICE_TYPE, OS, BROWSERDesktop, mobile, tablet, smarttv, wearable; OS and browser.
ClientLANGUAGE, USER_AGENTBrowser language and the raw user agent string.
SourceREFERRER, REFERRER_DOMAINFull referrer URL or just the referring domain.
BehaviorCLICKS_PER_IP, BOT_STATUSClick frequency per IP and automatic bot classification.
TrackingEXTERNAL_ID, TRACKING_FIELD_1..20Your external ID and sub1–sub20 custom parameters.
TimeWEEKDAY, TIME_OF_DAYDay of week and hour of day, in the campaign timezone.

Note that DATACENTER, PROXY, and BOT_STATUS are boolean dimensions — they are either true or false — which makes them ideal for one-line blocking rules. TRACKING_FIELD_1 through TRACKING_FIELD_20 map directly to sub1–sub20, so you can filter on any parameter your traffic source passes, such as a placement, zone, or campaign ID.

3. Every Operator

Operators define how the filter value is compared. BATracker supports text matching, list membership, numeric comparisons, IP ranges, regex, and emptiness/boolean checks:

CategoryOperatorsUse For
Equalityis / equals, is_notExact matches (e.g. COUNTRY is US).
Substringcontains, not_contains, starts_with, ends_withPartial text matches on user agents, referrers, sub IDs.
Listin_list, not_in_listMulti-country or multi-value allow/deny lists.
Numericgreater_than, less_than, greater_than_or_equals, less_than_or_equals, between, not_betweenCLICKS_PER_IP thresholds and time ranges.
IP Rangein_rangeCIDR blocks such as 192.168.0.0/24.
Regexregex, not_matches_regexPattern matching (capped at 500 chars for ReDoS safety).
Emptinessis_empty, is_not_emptyMissing referrers, empty sub IDs, blank user agents.
Booleanis_true, is_falseDATACENTER, PROXY, and BOT_STATUS checks.

The regex cap at 500 characters is a deliberate ReDoS (regular expression denial-of-service) safeguard — BATracker protects its own redirect performance so a runaway pattern can never slow down your traffic. For most blocking needs, contains, in_list, and in_range are faster to reason about than regex anyway.

4. Actions: BLOCK, REDIRECT, ALLOW, FLAG

When a rule matches, its action decides what happens to the visitor. BATracker gives you four:

BLOCK

Returns a 404, logs the click as filtered, and does NOT consume your visit quota. The ideal action for bots, datacenters, and proxies — you protect both your data and your plan usage.

REDIRECT

Sends a 302 to a fallback URL and logs the click as filtered. Use it to route unwanted traffic to a safe page, a backup offer, or your own site instead of the primary offer.

ALLOW

An explicit whitelist. Because the first matching rule wins, an early ALLOW rule guarantees a trusted segment passes before any later BLOCK rule can catch it.

FLAG

Allows the visitor through but marks the click for review. Perfect for suspicious-but-uncertain traffic you want to monitor before deciding to block it outright.

The fact that BLOCK returns a 404 and does not consume your visit quota is a genuine edge: aggressive filtering in BATracker saves plan usage rather than wasting it. Every bot you block is a visit you keep.

5. Templates vs Inline Filters

BATracker supports two layers of filtering, and understanding how they interact is key to a clean setup.

Filter Templates

Reusable rule sets you build once and share across campaigns. Each template has a status:

  • ACTIVE — enforced on every campaign it is attached to.
  • PAUSED — temporarily disabled without deleting.
  • ARCHIVED — retired but kept for reference.

Inline Filters

Configured per-campaign, and they take precedence over templates. Use inline rules for campaign-specific exceptions — for example, allowing a geo that your global template would otherwise block.

The recommended pattern: build one ACTIVE template with your universal defenses (BOT_STATUS, DATACENTER, PROXY) and attach it everywhere, then layer thin inline rules on individual campaigns for one-off targeting. Remember: across both layers, the first matching rule wins, and no match means the click is allowed.

6. Dayparting & Time Filters

The WEEKDAY and TIME_OF_DAY filter types let you restrict traffic to specific days and hours — classic dayparting to cut spend during hours that never convert. The critical detail: time filters evaluate in the campaign's timezone (IANA, default UTC), using Intl-based date parts.

This means dayparting matches exactly what you configured in the campaign — not the server clock. Set a campaign to America/New_York and a 9-to-5 window means 9-to-5 Eastern, every time, with no manual UTC math.

To restrict traffic to business hours, use TIME_OF_DAY between 09:00 and 17:00 — or invert it with not_between to block those hours. Combine WEEKDAY with in_list to run only on weekdays.

7. Practical Recipes

Here are copy-paste-ready rule patterns for the most common filtering goals. Each follows the same shape: filter type + operator + value → action.

Allow only specific countries

Add an early ALLOW rule: COUNTRY in_list US, CA, GB. Then add a catch-all BLOCK rule: COUNTRY not_in_list US, CA, GB → BLOCK. First match wins, so allowed geos pass and everything else is blocked.

Block datacenters and proxies

Two boolean rules: DATACENTER is_true → BLOCK and PROXY is_true → BLOCK. Real users almost never come from AWS, Google Cloud, Azure, OVH, Hetzner, or similar hosts, so this cuts obvious non-human traffic instantly.

Block detected bots

BOT_STATUS is_true → BLOCK. BATracker automatically classifies crawlers, scrapers, headless browsers, CLI tools (curl, wget, python-requests), search-engine bots, social preview bots, SEO crawlers, and AI crawlers (GPTBot, ClaudeBot) from the user agent — an empty user agent is treated as a bot too.

Throttle repeated clicks from one IP

CLICKS_PER_IP greater_than 5 → BLOCK. This catches the same address hammering your link — refreshers, click bots, and misconfigured sources — without penalizing normal shared-network traffic. Tune the threshold to your traffic profile.

IP CIDR blocklists

IP in_range 192.168.0.0/24 → BLOCK. Use CIDR notation to blackhole an entire range of known-bad addresses in a single rule instead of listing them one by one.

Regex user-agent blocks

USER_AGENT regex (curl|wget|python-requests) → BLOCK. For surgical control over specific tools or fingerprints. Patterns are capped at 500 characters for ReDoS safety, which keeps your redirects fast.

Dayparting to business hours

TIME_OF_DAY between 09:00 and 17:00 → ALLOW, with a following TIME_OF_DAY not_between 09:00 and 17:00 → BLOCK. Evaluated in the campaign timezone, so it stops the after-hours spend that never converts.

GoalFilter TypeOperator + ValueAction
Geo allow-listCOUNTRYin_list US, CA, GBALLOW
Kill datacentersDATACENTERis_trueBLOCK
Kill proxies/VPNsPROXYis_trueBLOCK
Kill botsBOT_STATUSis_trueBLOCK
Rate-limit IPsCLICKS_PER_IPgreater_than 5BLOCK
CIDR blocklistIPin_range 192.168.0.0/24BLOCK
DaypartingTIME_OF_DAYnot_between 09:00–17:00BLOCK

8. Frequently Asked Questions

What is the difference between filter templates and inline filters in BATracker?
Filter templates are reusable rule sets (status ACTIVE, PAUSED, or ARCHIVED) that you build once and share across many campaigns — perfect for standardizing your bot, datacenter, and proxy defenses. Inline filters are configured per-campaign and take precedence over templates, so you can layer campaign-specific exceptions on top of your global rules. In both cases, rules are evaluated in order and the first matching rule wins; if nothing matches, the click is allowed.
Does a blocked click count against my visit quota in BATracker?
No. When a filter rule with the BLOCK action matches, BATracker returns a 404, logs the click as filtered, and does NOT consume your visit quota. This means aggressive bot, datacenter, and proxy filtering actually protects your plan usage instead of burning through it. REDIRECT rules are also logged as filtered and send the visitor to a fallback URL with a 302.
How do I block traffic from datacenters, proxies, and bots?
BATracker automatically flags visitors from hosting and cloud ISPs (AWS, Google Cloud, Azure, DigitalOcean, OVH, Hetzner, and more) with connection type "datacenter", flags proxies/VPNs with the PROXY dimension, and detects bots from the user agent (crawlers, headless browsers, CLI tools, SEO and AI crawlers). You act on these with filter rules: BLOCK where DATACENTER is_true, BLOCK where PROXY is_true, and BLOCK where BOT_STATUS is_true. Combine them in one template for a strong first line of defense.
Can I set up dayparting with BATracker traffic filters?
Yes. Use the WEEKDAY and TIME_OF_DAY filter types with operators like in_list, between, or not_between. For example, a rule using TIME_OF_DAY with the between operator set to 09:00–17:00 restricts traffic to business hours. Time filters evaluate in the campaign timezone (IANA, default UTC) using Intl-based date parts, so your dayparting matches exactly what you configured — not the server clock.
How do I block a range of IP addresses in BATracker?
Use the IP filter type with the in_range operator and CIDR notation, for example 192.168.0.0/24 to cover an entire block. For known abusive single addresses, use the IP type with is or in_list. To catch repeated clicks from the same address, use CLICKS_PER_IP with greater_than and a threshold. BATracker also supports regex on the USER_AGENT field (capped at 500 characters for ReDoS safety) for surgical blocks of specific tools.

Stop Paying for Bots, Datacenters & Proxies

BATracker's filtering engine blocks junk traffic before it counts — 404 on block, zero visit quota consumed, evaluated in real time at sub-10ms speed. Build one template, protect every campaign.

Start Your Free Trial