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 evaluates each deployed layout in priority order and picks the first match:
Higher-priority layouts are checked first. See Layout priorities for detail.
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 |
|---|---|
| Include browsers | Only apply this layout on selected browsers (e.g. Chrome, Safari) |
| Include 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.
Priority when patterns overlap
When two layouts could both match a URL, the higher-priority layout wins — lower priority numbers run earlier. A common pattern:
| Layout | Pattern | Audience | Priority | Purpose |
|---|---|---|---|---|
| Sports articles | Starts with /article/ | (plus key-value section = sports) | 5 | More specific — wins on sports |
| Article pages | Starts with /article/ | — | 10 | Catches other articles |
| Default | Regex match .* | — | 100 | Fallback so every page has a layout |
See Layout priorities for how to think about numeric values and ordering.
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 → Create Release
- Check that no audience filter is excluding your test browser or device
- Check priority order — a higher-priority layout on a broader pattern may be matching first
See Wrapper Debugging for more console-side signals.
Best practices
Do
- Be specific before generic — a narrow layout at higher priority, a default
.*regex at lowest priority - Document what each pattern matches in the release notes when shipping
- Always ship a fallback layout so every page has one
Don't
- Overlap without priority — causes confusion and unpredictable matching
- 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
- Put a more specific layout at a higher priority for the URLs you want to skip
- Use key-value targeting on the layout and set the key-value conditionally on your pages