Skip to content

Conditional Routing Rules

TL;DR: You set rules that redirect visitors to different destination URLs based on conditions: visitor country, total click count on the link, or a date range. Rules are evaluated in priority order — the first matching rule wins. If no rule matches, the default destination is used.

Redirect visitors to different destinations based on their country, click thresholds, dates, or any combination of conditions — all on a per-link basis.

What Are Conditional Rules

A conditional rule overrides a link's default destination URL when its conditions match. Each link can have multiple rules, evaluated in priority order. The first rule that matches wins. If no rules match, the visitor goes to the link's default target URL.

You configure conditional rules from within the link editor, under the Conditional Routing Rules section.

Conditional rules overview

Rule Fields

Each rule has the following fields:

FieldTypeDescription
nameText, optional (max 120 characters)Descriptive label for the rule (e.g., "US visitors to US store")
is_activeBoolean (default: true)Toggle the rule on or off without deleting it
priorityInteger, 0–100 (default: 100)Evaluation order — lower numbers evaluate first
match_modeall or anyHow conditions combine: all = every condition must match (AND), any = at least one must match (OR)
target_urlURLAlternate destination for visitors who match this rule
redirect_type301, 302, or 307HTTP redirect status code for this rule
start_atDatetime (optional)Rule activates after this date and time
end_atDatetime (optional)Rule deactivates after this date and time
conditionsArray (optional)Condition objects (see below). If empty, the rule matches all visitors within its date window.

Condition Types

Each condition checks a specific attribute of the click against your defined criteria.

TypeDescriptionOperatorsValue Format
total_clicksTotal click count on the link (evaluated as what the count will be after the current click)gt, gte, eq, lt, lteNumber
country_inVisitor's country, resolved from GeoLite2 database or Cloudflare/CDN headersinArray of 2-letter ISO country codes (e.g., ["US", "CA"])
date_afterCurrent date is after a specified dategt, gteDate string (e.g., "2026-04-01")
date_beforeCurrent date is before a specified datelt, lteDate string (e.g., "2026-06-30")

Operator Reference

OperatorMeaning
gtGreater than
gteGreater than or equal to
eqEqual to
ltLess than
lteLess than or equal to
inValue is in the provided list

Match Modes

The match mode determines how multiple conditions within a single rule combine.

All (AND Logic)

Every condition in the rule must be true for the rule to match.

Example: A rule with match mode all and two conditions — country_in: ["US"] and total_clicks lt 500 — only matches visitors from the US when the link has fewer than 500 total clicks.

Any (OR Logic)

At least one condition must be true for the rule to match.

Example: A rule with match mode any and two conditions — country_in: ["US"] and country_in: ["CA"] — matches visitors from either the US or Canada.

Priority and Evaluation Order

Rules evaluate in ascending priority order. A rule with priority 10 evaluates before a rule with priority 100. The first rule that matches determines the redirect destination.

Evaluation Flow

  1. Link Manager Pro loads all active rules for the link, sorted by priority (lowest first).
  2. For each rule:
    • Check if the current date falls within the start_at/end_at window (if set). Skip the rule if outside the window.
    • Evaluate all conditions using the rule's match mode.
    • If the rule matches → redirect the visitor to this rule's target_url using this rule's redirect_type. Stop evaluating.
  3. If no rule matches → redirect to the link's default target_url.

Rule evaluation flow diagram

Date Range Restrictions

Use start_at and end_at to limit when a rule is active, independent of its conditions.

FieldBehavior
start_at onlyRule activates on that date and stays active indefinitely
end_at onlyRule is active immediately and deactivates on that date
Both setRule is active only between start_at and end_at
Neither setRule is always eligible for evaluation (conditions still apply)

Date range checks happen before condition evaluation. If the current date is outside the range, the rule is skipped entirely.

Creating a Rule

  1. Go to Link Manager → Pretty Links.
  2. Click a link to open the link editor.
  3. Scroll to the Conditional Routing Rules section.
  4. Click Add Rule.
  5. Fill in the rule fields:
    • Enter a descriptive name.
    • Set the priority (lower = evaluated first).
    • Choose the match mode (all or any).
    • Enter the target URL for this rule's redirect.
    • Select the redirect type (301, 302, or 307).
    • Optionally set start_at and end_at dates.
  6. Add one or more conditions:
    • Select the condition type.
    • Choose the operator.
    • Enter the value.
  7. Click Save.

Creating a conditional rule

Use Case Examples

Geo-Targeting: Regional Storefronts

Redirect visitors to their regional store based on country.

Setup: Create two rules on the same link.

Rule 1 — US Store (priority 10):

  • match_mode: all
  • target_url: https://us.store.com/product
  • redirect_type: 302
  • Condition: country_inin["US"]

Rule 2 — EU Store (priority 20):

  • match_mode: all
  • target_url: https://eu.store.com/product
  • redirect_type: 302
  • Condition: country_inin["DE", "FR", "IT", "ES", "NL"]

Visitors from the US go to the US store. Visitors from listed EU countries go to the EU store. Everyone else goes to the link's default target URL.

Click Cap: Redirect After a Threshold

Send visitors to a different page after a link reaches a click threshold.

Rule — Redirect after 1000 clicks (priority 10):

  • match_mode: all
  • target_url: https://yoursite.com/sold-out
  • redirect_type: 302
  • Condition: total_clicksgte1000

The first 999 visitors go to the default destination. Starting at click 1000, visitors redirect to the sold-out page.

Time-Limited Promotion

Redirect to a sale page only during a specific date range.

Rule — Holiday sale (priority 10):

  • match_mode: all
  • target_url: https://yoursite.com/holiday-sale
  • redirect_type: 302
  • start_at: 2026-12-20 00:00:00
  • end_at: 2026-12-31 23:59:59

No conditions needed — the date range restriction alone controls when this rule is active. Outside the date window, visitors go to the default destination.

Combining Conditions: Geo + Date

Redirect US visitors to a Black Friday page during a specific window.

Rule — US Black Friday (priority 10):

  • match_mode: all
  • target_url: https://yoursite.com/black-friday
  • redirect_type: 302
  • Condition 1: country_inin["US"]
  • Condition 2: date_aftergte"2026-11-27"
  • Condition 3: date_beforelte"2026-11-30"

Because match mode is all, all three conditions must be true. Only US visitors between November 27 and November 30 see the Black Friday page.

Managing Rules

Editing a Rule

  1. Open the link editor.
  2. Find the rule in the Conditional Routing Rules section.
  3. Modify any fields or conditions.
  4. Click Save.

Deleting a Rule

  1. Open the link editor.
  2. Click the Delete button on the rule you want to remove.
  3. Confirm the deletion.

Reordering Rules

Change the priority value on each rule to control evaluation order. Lower numbers evaluate first. You do not need consecutive numbers — values like 10, 20, 30 work well and leave room for inserting rules later.

Syncing Rules (Bulk Replace)

The sync operation performs an atomic replace of all rules on a link. It removes every existing rule and replaces them with a new set in a single operation. Use sync when you need to restructure all rules on a link at once rather than editing them individually.

Troubleshooting

If a conditional rule is not triggering as expected, check each item in this list:

CheckWhat to Verify
Rule is activeConfirm is_active is set to true
Priority orderA higher-priority rule (lower number) may be matching first — review all rules on the link
Date rangeIf start_at or end_at is set, confirm the current date falls within the window
Match modeIf set to all, every condition must be true — check that all conditions can be satisfied simultaneously
Country detectionCountry code relies on GeoLite2 or Cloudflare/CDN headers — verify your server provides this data
Click count timingtotal_clicks evaluates against the count after the current click, not before — a gte 1000 condition triggers on the 1000th click
Condition valuesDouble-check country codes are valid 2-letter ISO codes and date strings are formatted correctly
Link targetConfirm the rule's target_url is a valid, accessible URL

If no rules match, the link uses its default target URL. This is expected behavior, not an error.


Step-by-step guide: How to Create Redirect Links in WordPress