Skip to content
Last updated: 2026-04-06
Reference

Rules and Conditions

Rules are the decision-making engine of Dxtra Tag Manager. Each rule combines events, conditions, exceptions, and actions to control when and what happens on your pages.

Rule Logic

Every rule follows this evaluation pattern:

Text Only
IF (any Event matches)
AND (all Conditions are true)
AND NOT (any Exception is true)
THEN (execute Action Groups)
  • Events: At least one event must fire (OR logic)
  • Conditions: All conditions must be true (AND logic)
  • Exceptions: If any exception is true, the rule is blocked (NOT logic)
  • Actions: All action groups execute (subject to distribution settings)

Conditions

Conditions compare a value from a data container against an expected value using an operator.

Condition Structure

Each condition has three parts:

  1. Variable: A value from a data container, using template syntax
  2. Operator: How to compare the values
  3. Value: The expected value to compare against

Template Syntax

Reference data container values using double curly braces:

Text Only
{{Container.Key}}

Examples:

Template Source
{{QueryString.utm_source}} URL query parameter
{{Browser.userAgent}} Browser user agent string
{{Environment.GA_TRACKING_ID}} Environment variable
{{AppState.user_logged_in}} App state variable
{{LocalStorage.preference}} Browser local storage value
{{Custom.campaign_type}} Custom data container value
{{ElementClick.href}} Clicked element's href attribute
{{BrowserError.message}} JavaScript error message

Operators

Operator Description Example
Equal Exact match {{QueryString.page}} Equal home
Not Equal Does not match {{Browser.language}} Not Equal en
Contains Substring match {{Browser.userAgent}} Contains Mobile
Begins With Starts with {{QueryString.utm_source}} Begins With google
Ends With Ends with {{Browser.url}} Ends With .pdf
Regular Expression Regex match {{Browser.url}} Regular Expression \/product\/\d+
Greater Than Numeric > {{AppState.cart_total}} Greater Than 100
Greater Than Equal Numeric >= {{AppState.page_views}} Greater Than Equal 5
Less Than Numeric < {{AppState.error_count}} Less Than 3
Less Than Equal Numeric <= {{Custom.score}} Less Than Equal 50
Is Defined Value exists {{QueryString.promo}} Is Defined
Is Not Defined Value missing {{LocalStorage.returning_user}} Is Not Defined

Exceptions

Exceptions use the same structure as conditions but act as blockers. If any exception evaluates to true, the rule does not execute, regardless of whether events and conditions are met.

Use exceptions for:

  • Excluding specific pages (e.g., privacy policy pages)
  • Blocking rules for certain user agents (e.g., bots)
  • Preventing duplicate tracking

Rule Priority

When multiple rules could fire simultaneously, priority determines execution order. Lower priority values execute first.

Best practices:

  • 1-10: Critical rules (consent, essential functionality)
  • 11-50: Standard tracking rules
  • 51-100: Optional or supplementary rules

Common Rule Patterns

Universal Page Tracking

Track all page views with no conditions:

Text Only
Event: Page Loaded
Conditions: (none)
Exceptions: (none)
Action: Track Event "page_view"

Conditional Tracking

Track only specific pages:

Text Only
Event: Page Loaded
Condition: {{Browser.url}} Contains "/products/"
Action: Track Event "product_page_view"

Only fire when analytics consent is granted:

Text Only
Event: CMP Check
Condition: CMP analytics consent equals "true"
Action: Load JS (analytics script)

Exclude Specific Pages

Track everything except the privacy policy:

Text Only
Event: Page Loaded
Conditions: (none)
Exception: {{Browser.url}} Contains "/privacy-policy"
Action: Track Event "page_view"

Click Tracking with Context

Track button clicks with additional context:

Text Only
Event: Click Elements (CSS: ".purchase-btn")
Condition: {{AppState.user_logged_in}} Equal "true"
Action: Track Event "purchase_click"

Time-Based Engagement

Track users who stay on a placement for a set time:

Text Only
Event: Tag Timer (delay: 30000ms)
Conditions: (none)
Action: Track Event "engaged_30_seconds"

Testing Rules

  1. Deploy to your development environment
  2. Navigate to the page with #dxtra-debug in the URL
  3. The debug overlay shows:
    • Which rules are being evaluated
    • Which conditions passed or failed
    • Which actions executed
    • A timeline of rule evaluation