Decide which pages a rule runs on
Segments decide who a rule is for. Page targeting decides where it runs. Every redirect, bar, popup, block, and content rule has a page targeting setting, and you pick one of three options.
GeoSwap checks your pattern against two versions of the page address, and a match on either one counts:
https://www.example.com/shop/lamp?color=red
Use this when the domain matters. Start your pattern with ^https?://.
/shop/lamp
Use this for pages on any of your sites. Start your pattern with ^/.
Upper and lower case don't matter. Query strings like ?utm_source=ad won't stop a path pattern from matching. If a pattern isn't valid regex, the rule simply won't run anywhere, so test it with the dashboard's Simulate Rules tool before you rely on it.
Say you run example.com and example.in with the same GeoSwap script, and you want visitors from India on example.com to land on the same page on example.in. Set page targeting to URL pattern with ^https?://(www\.)?example\.com/, then give the India rule a Swap domain destination of https://example.in. Visitors on example.com/products/lamp go to example.in/products/lamp, and nobody on example.in gets redirected.
Replace example.com and the paths with your own. The same examples appear in the Pattern Guide next to the pattern field in the dashboard.
^https?://(www\.)?example\.com/Use this when the same script runs on several of your sites and the rule should fire on only one of them — e.g. send a segment from example.com to example.in with Swap domain. Covers the domain with and without www.
✓ example.com/
✓ www.example.com/shop/lamp?utm_source=ad
✗ example.in/
✗ shop.example.com/
^https?://([a-z0-9-]+\.)*example\.com/Like the one above, but also covers shop.example.com, blog.example.com and so on.
✓ example.com/
✓ shop.example.com/cart
✗ example.co/
✗ notexample.com/
^https?://(?!(www\.)?example\.in/)Fires everywhere your script runs except one domain (with or without www). Handy when one script is installed on several sites.
✓ example.com/pricing
✓ shop.example.com/
✗ example.in/
✗ www.example.in/pricing
^https?://(www\.)?example\.com/blog(/|[?#]|$)Only the /blog section of example.com — the same section on your other sites is left alone.
✓ example.com/blog
✓ www.example.com/blog/my-post
✗ example.in/blog
✗ example.com/blogger
^/products/?$A pattern starting with ^/ is checked against the page's path, so it works on every site your script runs on. /? allows an optional trailing slash; query strings (?utm_source=…) are fine.
✓ example.com/products
✓ www.example.in/products/?utm_source=ad
✗ example.com/products/shoes
^/(pricing|about|contact)/?$List the pages between the brackets, separated by |.
✓ example.com/pricing
✓ example.com/about/
✓ example.com/contact?ref=nav
✗ example.com/pricing/enterprise
^/blog(/.*)?$The page itself plus every page below it. Won't catch look-alikes such as /blogger.
✓ example.com/blog
✓ example.com/blog/2024/intro
✓ example.com/blog?page=2
✗ example.com/blogger
^/shop/.+Pages below /shop, but not /shop itself.
✓ example.com/shop/shoes
✓ example.com/shop/hats?size=m
✗ example.com/shop
✗ example.com/shop/
summerMatches the word anywhere in the address — domain, path or query string.
✓ example.com/summer-sale
✓ example.com/products/summer-collection
✗ example.com/winter-sale
\.pdf$Any page whose path ends in .pdf, even with a query string after it.
✓ example.com/report.pdf
✓ example.com/docs/guide.pdf?download=1
✗ example.com/pdf-tools
With All pages or Specific URLs, you can also list pages the rule should skip, like your checkout or account pages. Each entry can be a full URL, a path, or a pattern, and exclusions follow the same matching rules as URL patterns.
A plain entry matches anywhere in the address, so /admin also skips /admin-tips. To skip only /admin and the pages under it, use ^/admin(/|$).
Start broad and narrow down. Most sites only need All pages plus an exclusion or two.
Installed the script on several sites? Use a full-address pattern whenever a rule should only run on one of them.
Anchor your patterns. ^/blog matches the blog section, while a bare blog also matches /catalog/blog-ideas.
Check your pattern with Simulate Rules in the dashboard before you publish it.
Send each audience to the right page, or swap them onto another domain.