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
| Variable | Tag Version | Use Case |
|---|---|---|
window._conv_page_type | v0 | Page type classification |
window.convert_page_type | v1 | Page type (alternative) |
window._conv_category_name | v2 | Product/content category |
window._conv_product_name | v3 | Product name |
window._conv_search_term | v4 | Search query |
window._conv_custom_v1 through window._conv_custom_v10 | v5 | 10 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
v0equalsproduct - 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
| Approach | Best For | Timing |
|---|---|---|
| Page Tags | Static page-level data known at render time | Must be set before tracking script loads |
| Custom Variables | Dynamic data available after page load | Can be set any time, then trigger re-evaluation |
| JavaScript Conditions | Complex logic, data layer checks, computed conditions | Evaluated when rules are processed |
Updated about 1 month ago