Triggers & Targeting
Control when the widget appears and who sees it.
How Triggers Work
Trigger Options
Configure when the widget should appear.
Delay Trigger
Show after a specified delay:
- HTML
- JavaScript
<pollarix-widget
collector-id="YOUR_ID"
api-key="YOUR_KEY"
delay="5000"
></pollarix-widget>
widget.configure({
triggers: {
delay: 5000 // 5 seconds
}
});
Scroll Depth Trigger
Show when user scrolls to a percentage of the page:
- HTML
- JavaScript
<pollarix-widget
collector-id="YOUR_ID"
api-key="YOUR_KEY"
scroll-depth="50"
></pollarix-widget>
widget.configure({
triggers: {
scrollDepth: 50 // 50% of page
}
});
Page Views Trigger
Show after the user has visited a number of pages in the session:
- HTML
- JavaScript
<pollarix-widget
collector-id="YOUR_ID"
api-key="YOUR_KEY"
page-views="3"
></pollarix-widget>
widget.configure({
triggers: {
pageViews: 3 // After 3 page views
}
});
Exit Intent Trigger
Show when the user appears to be leaving the page:
- HTML
- JavaScript
<pollarix-widget
collector-id="YOUR_ID"
api-key="YOUR_KEY"
exit-intent="true"
></pollarix-widget>
widget.configure({
triggers: {
exitIntent: true
}
});
Exit Intent Detection
The widget uses multiple signals to detect exit intent:
- Mouse moving toward browser chrome (desktop)
- Tab switching
- Rapid scroll toward top of page
- Extended idle time
Custom Event Trigger
Show when a custom JavaScript event fires:
- HTML
- JavaScript
<pollarix-widget
collector-id="YOUR_ID"
api-key="YOUR_KEY"
on-event="checkout-complete"
></pollarix-widget>
widget.configure({
triggers: {
onEvent: 'checkout-complete'
}
});
// Trigger the widget from your code
document.dispatchEvent(new CustomEvent('checkout-complete'));
Combining Triggers
You can combine multiple triggers. The widget shows when any trigger fires:
widget.configure({
triggers: {
delay: 10000, // After 10 seconds
scrollDepth: 75, // OR after 75% scroll
exitIntent: true, // OR on exit intent
}
});
Targeting Rules
Control which users and pages see the widget.
URL Matching
Show only on specific URLs:
- HTML
- JavaScript
<pollarix-widget
collector-id="YOUR_ID"
api-key="YOUR_KEY"
url-match="/checkout/*"
></pollarix-widget>
widget.configure({
targeting: {
urlMatch: '/checkout/*'
}
});
URL Exclusion
Hide on specific URLs:
widget.configure({
targeting: {
urlExclude: '/admin/*'
}
});
URL Pattern Syntax
| Pattern | Matches |
|---|---|
/checkout | Exact match |
/checkout/* | /checkout/ and one segment after |
/checkout/** | /checkout/ and any path after |
**/success | Any URL ending in /success |
Device Targeting
Target specific device types:
- HTML
- JavaScript
<pollarix-widget
collector-id="YOUR_ID"
api-key="YOUR_KEY"
device="desktop"
></pollarix-widget>
widget.configure({
targeting: {
device: 'desktop' // 'desktop' | 'mobile' | 'all'
}
});
| Value | Description |
|---|---|
all | All devices (default) |
desktop | Desktop browsers only |
mobile | Mobile devices only |
Frequency Capping
Prevent survey fatigue by limiting how often users see the widget.
widget.configure({
frequency: {
minDaysBetween: 90, // Wait 90 days between displays
maxShowsPerUser: 3, // Show maximum 3 times ever
}
});
Testing with Force Show
During development, bypass frequency capping:
<pollarix-widget
collector-id="YOUR_ID"
api-key="YOUR_KEY"
force-show="true"
></pollarix-widget>
Clearing Throttle Data
Reset frequency data for testing:
// Via widget instance
widget.clearThrottle();
// Via global API
window.Pollarix.clearThrottle();
Complete Targeting Example
widget.configure({
// Show after 5 seconds OR on checkout pages
triggers: {
delay: 5000,
onEvent: 'checkout-complete',
},
// Only on product and checkout pages, not admin
targeting: {
urlMatch: '/products/**,/checkout/**',
urlExclude: '/admin/**',
device: 'all',
},
// Limit to once every 30 days, max 2 times
frequency: {
minDaysBetween: 30,
maxShowsPerUser: 2,
},
});
Trigger Reference
| Trigger | HTML Attribute | JS Property | Description |
|---|---|---|---|
| Delay | delay | triggers.delay | Milliseconds to wait |
| Scroll | scroll-depth | triggers.scrollDepth | Percentage (0-100) |
| Page Views | page-views | triggers.pageViews | Number of pages |
| Exit Intent | exit-intent | triggers.exitIntent | Boolean |
| Custom Event | on-event | triggers.onEvent | Event name string |
Targeting Reference
| Rule | HTML Attribute | JS Property | Description |
|---|---|---|---|
| URL Match | url-match | targeting.urlMatch | Glob pattern |
| URL Exclude | url-exclude | targeting.urlExclude | Glob pattern |
| Device | device | targeting.device | Device type |
Next Steps
- Styling - Customize widget appearance
- Events & API - Handle widget events
- Examples - Common use cases
Was this page helpful?