Layout Targeting
A layout's targeting decides which pages it applies to. Configured on the layout's Scope tab, targeting has two parts: Page Paths (URL path matching) and Audience (browser / device filters).
For the step-by-step of filling in a new layout, see Creating a layout.
How targeting resolves
When a page loads, the wrapper keeps every deployed layout whose Page Paths match the URL and whose Audience includes the visitor. There's no priority and no first-match — all matching layouts apply together. Their ad slots are combined and their Targeting key-values are merged.
Matching depends only on Page Paths and Audience — never on a layout's Targeting key-values (those are applied after a layout matches; see Using targeting key-values). Because matches aggregate, keep layout scopes disjoint unless you intend their slots to stack, and remember a Regex: .* layout matches every page.
Page-path pattern types
Each rule under Scope → Page Paths has a pattern type and a path value. Only the path portion of the URL is matched — query strings (?foo=bar) and hash fragments (#anchor) are stripped before matching.
| Pattern type | Meaning | Example path | Matches | Doesn't match |
|---|---|---|---|---|
| Exact match | Path must be identical | / | / | /about, /foo/ |
| Exact match | /about | /about | /about/team, /about-us | |
| Starts with | Path must begin with the value | /article/ | /article/foo, /article/2024/bar | /articles/foo, /article |
| Starts with | /blog/ | /blog/post-1, /blog/tech/foo | /blog | |
| Contains | Value appears anywhere in the path | /news/ | /us/news/2024/foo, /news/top | /newsletter/foo |
| Ends with | Path must end with the value | .amp | /article/foo.amp | /article/foo |
| Ends with | /amp | /article/foo/amp | /article/foo | |
| Regex match | Regular-expression match against the path | ^/article/[0-9]+$ | /article/12345 | /article/foo, /article/12345/comments |
Regex tips (from the in-portal popover)
^= start,$= end of path.= any char,.*= any chars[0-9]+= one or more digits(a|b)= matches "a" OR "b"
Earlier versions of these docs used *-style wildcards (/article/*). The portal uses typed pattern matching instead — choose Starts with for the equivalent of /article/*, or Regex match when you need more flexibility.
Combining page paths
A layout can have multiple page-path rules. A page matches the layout if any of the rules match. Use this to group related sections under one layout:
Layout: Article Pages
Scope → Page Paths:
pattern: Starts with path: /article/
pattern: Starts with path: /blog/
pattern: Starts with path: /news/
pattern: Starts with path: /story/
All four use the same slots and settings.
Audience filters
Under Scope → Audience, you can further narrow a layout to specific browsers or devices:
| Field | What it does |
|---|---|
| Browsers | Only apply this layout on selected browsers (e.g. Chrome, Safari) |
| Devices | Only apply this layout on selected device categories (mobile, desktop, tablet) |
Left empty, the layout applies to all browsers and devices. This is the right place to split mobile vs. desktop experiences where layouts genuinely differ, rather than juggling per-slot size lists.
When patterns overlap
Because matches aggregate, two layouts that both match a URL both apply — the page loads the union of their slots. There's no key-value or priority tiebreak that makes one "win," so design overlapping scopes intentionally:
| Goal | How to express it |
|---|---|
Different slots on /article/ sports vs. other articles | Use distinct, non-overlapping Page Paths (e.g. Starts with /article/sports/ vs. a scope that excludes it), or split by Audience |
| A baseline of slots on every page | A Regex: .* layout — its slots load site-wide, on top of any specific layout |
| Slots that stack on a section | Overlap deliberately — e.g. an /article/ layout plus a narrower /article/longform/ layout, both matching longform articles |
The pitfall to avoid is accidental overlap: two layouts you thought were mutually exclusive both matching the same URL and double-loading a slot.
Using targeting key-values
Beyond URL paths, targeting key-values passed into the auction (e.g. via googletag.pubads().setTargeting('section', 'sports') on your page) can be used for GAM-side line-item targeting. Layout-level key-values are configured on the Targeting tab of the layout form.
Layout key-values are applied on every impression from the matched layout; per-slot key-values override at the slot level.
Testing targeting
Anima doesn't have a dedicated preview URL — test against the live config on any page that has the wrapper installed.
Debug logs
Append ?pbjs_debug=true to the URL and reload. Filter DevTools Console for AAM. You should see:
AAM Processing <N> ad slots on page
<N> equals the slot count on whichever layout matched. <N> === 0 means no layout matched.
Debugging no match
If no layout matches the URL you're testing:
- Check the exact path — trailing slashes matter; query strings and hash fragments are stripped before matching
- Verify the pattern type matches your intent (Starts with vs. Contains vs. Exact)
- Confirm the layout is in the currently deployed release — edits don't take effect until Wrapper → Releases → + Release
- Check that no audience filter is excluding your test browser or device
See Wrapper Debugging for more console-side signals.
Best practices
Do
- Keep scopes disjoint — a page should match only the layouts whose slots you want on it
- Document what each pattern matches in the release notes when shipping
- Use a
Regex: .*layout only when you want a set of slots on every page
Don't
- Overlap scopes by accident — matches stack, so a stray overlap double-loads slots
- Forget trailing-slash edge cases (
/blogvs./blog/) - Use regex for matches that a simpler Starts with or Ends with would express more clearly
Common questions
Does case matter?
URL matching is typically case-sensitive at the path level. Test with the actual URLs your site serves.
How do I target query parameters?
Page paths only match the path — query strings are stripped. If you need query-based targeting, read the query on your own site and pass it as a GAM key-value:
const section = new URLSearchParams(location.search).get('section');
googletag.pubads().setTargeting('section', section);
Then use key-value targeting at the layout or slot level.
Can I exclude URLs from a layout?
Not directly. Options:
- Use a more precise pattern (e.g. regex with exclusion logic) so only the URLs you want match
- Narrow the layout's scope so it stops matching the URLs you want to skip — remember there's no priority override, so an excluded URL must simply fail every rule on that layout
- Use key-value targeting on the layout and set the key-value conditionally on your pages