Page Tags & Custom Variables

Overview

Page tags and custom variables let you pass your own data into the tracking script for use in targeting rules. This is useful when you need to target based on information that isn't available in the URL, cookies, or standard visitor attributes — like product categories, user plans, or data layer values.

Page Tags (Window Variables)

Page tags are predefined window variables that the tracking script reads during rule evaluation. Set them before the tracking script loads:

<script>
  window._conv_page_type = "product";
  window._conv_category_name = "Electronics";
  window._conv_product_name = "Wireless Headphones";
  window._conv_search_term = "bluetooth headphones";
</script>
<!-- Convert tracking script loads after -->

Available Page Tag Variables

VariableTag VersionUse Case
window._conv_page_typev0Page type classification
window.convert_page_typev1Page type (alternative)
window._conv_category_namev2Product/content category
window._conv_product_namev3Product name
window._conv_search_termv4Search query
window._conv_custom_v1 through window._conv_custom_v10v510 general-purpose custom variables

Using Page Tags in Targeting

In the Convert UI, create a Page Tag audience rule and select the tag version. The rule evaluates the corresponding window variable using comparison operators (equals, contains, regex, etc.).

Example: Target only product pages:

  • Rule: Page Tag v0 equals product
  • This checks if window._conv_page_type === "product"

Custom Variables (Runtime API)

Custom variables are set at runtime via the JavaScript API. Unlike page tags (which must be set before the script loads), custom variables can be set at any time:

window._conv_q = window._conv_q || [];
window._conv_q.push({
  what: 'setIntegrationVariable',
  params: { key: 'user_plan', value: 'enterprise' }
});

Using Custom Variables in Targeting

In the Convert UI, create a Custom Variable audience rule:

  • Key: user_plan
  • Operator: Equals
  • Value: enterprise

Custom variables are evaluated at rule processing time. If the variable is set after the script has already processed experiences, call run or checkExperiences to trigger re-evaluation:

// Set the variable
window._conv_q.push({
  what: 'setIntegrationVariable',
  params: { key: 'user_plan', value: 'enterprise' }
});

// Re-evaluate experiences
window._conv_q.push({ what: 'checkExperiences' });

JavaScript Condition Rules

For complex targeting that doesn't fit the page tag or custom variable model, use a JavaScript Condition rule. This evaluates arbitrary JavaScript code:

// Example: Target visitors who have items in their cart
return window.dataLayer?.some(e => e.event === 'add_to_cart');

The code must return true (visitor qualifies) or false (visitor doesn't qualify). It runs in the page context with full access to the DOM and window object.

When to Use Each

ApproachBest ForTiming
Page TagsStatic page-level data known at render timeMust be set before tracking script loads
Custom VariablesDynamic data available after page loadCan be set any time, then trigger re-evaluation
JavaScript ConditionsComplex logic, data layer checks, computed conditionsEvaluated when rules are processed