Active On Site Tracking Guide
Learn about the OIR SDK's automatic engagement tracking.
The Active On Site event is automatically collected by the SDK when a user stays on your website long enough to meet the configured time threshold. This event marks the start of the user's engagement journey and is triggered once per web session.
- User lands on your website
- SDK starts tracking time on site
- When the user meets the minimum time threshold, the event fires
- Event is sent once per session (not on every page load)
- Automatic Collection: No manual implementation required
- Time-Based Trigger: Only fires after the user meets the minimum time threshold
- Session-Based: Triggers once per web session
- Engagement Indicator: Identifies genuinely interested users vs. quick bounces
- Cross-Tab Coordination: Only one tab sends the event
- Engagement Analytics: Track users who spend meaningful time on your site
- Conversion Funnel: Use as a starting point for conversion tracking
- Audience Segmentation: Identify engaged users for remarketing campaigns
- Content Performance: Measure which pages lead to longer engagement
- Bounce Rate Analysis: Distinguish between quick bounces and engaged sessions
- Active User Tracking: Identify users who are actively engaged
- Reduced Noise: Filters out accidental clicks and quick bounces
- Quality Metrics: Focus on users who show genuine interest
- Better Targeting: Create audiences based on engagement behavior
- Improved ROI: Target users who are more likely to convert
The time threshold is configured in your dashboard. By default, the event fires after 15 seconds of time on site.
You can attach custom data to the automatic Active On Site event using global configuration:
window._oirtrk = window._oirtrk || [];
// Set global custom data that will be included in automatic events
window._oirtrk.push(['set', 'sessionId', getSessionId()]);
window._oirtrk.push(['set', 'customId', 'user_12345']);
window._oirtrk.push(['set', 'campaignId', 'summer_sale_2024']);
window._oirtrk.push(['set', 'userSegment', 'premium']);
This data will be automatically included when the Active On Site event fires.
If you need to manually trigger this event (not recommended for most use cases):
_oirtrk.push([
'event',
{
event: 'on_site',
page_url: window.location.href,
page_title: document.title,
referrer: document.referrer,
// Custom fields
sessionId: getSessionId(),
customId: 'user_12345',
campaignId: 'summer_sale_2024',
},
]);
You can include additional custom fields with the On Site event:
| Category | Examples |
|---|---|
| Session Data | sessionId, sessionDuration, sessionStartTime |
| User Identifiers | customId, puid, customerId |
| Business Context | campaignId, source, medium, content |
| Technical Data | deviceType, browserVersion, screenResolution |
Note: Custom fields need to be registered in your dashboard before they can be used.
If you're upgrading from a previous version of the SDK, you may have a manual on-site tracking snippet following your SDK loader. Since the SDK now handles on-site events automatically, we recommend removing this second script block.
Current setup (before migration):
<script type="text/javascript">
!(function (s) {
let o = s.createElement('script'),
u = s.getElementsByTagName('script')[0];
o.src = 'https://cdn.aggle.net/oir/oir.min.js';
o.async = !0;
o.setAttribute('oirtyp', 'YOUR_INTEGRATION_TYPE');
o.setAttribute('oirid', 'YOUR_INTEGRATION_ID');
u.parentNode.insertBefore(o, u);
})(document);
</script>
<!-- Remove this second script block -->
<script type="text/javascript">
!(function (e) {
let t = {
puid: '12345',
};
(e._oirtrk = e._oirtrk || []).push(['track', 'on-site', t]);
})(window);
</script>
Recommended setup (after migration):
<script type="text/javascript">
!(function (s) {
let o = s.createElement('script'),
u = s.getElementsByTagName('script')[0];
o.src = 'https://cdn.aggle.net/oir/oir.min.js';
o.async = !0;
o.setAttribute('oirtyp', 'YOUR_INTEGRATION_TYPE');
o.setAttribute('oirid', 'YOUR_INTEGRATION_ID');
u.parentNode.insertBefore(o, u);
})(document);
</script>
If you need custom data with the on-site event, use the set command instead:
<script type="text/javascript">
!(function (s) {
let o = s.createElement('script'),
u = s.getElementsByTagName('script')[0];
o.src = 'https://cdn.aggle.net/oir/oir.min.js';
o.async = !0;
o.setAttribute('oirtyp', 'YOUR_INTEGRATION_TYPE');
o.setAttribute('oirid', 'YOUR_INTEGRATION_ID');
u.parentNode.insertBefore(o, u);
})(document);
// Set custom data that will be included in automatic events
window._oirtrk = window._oirtrk || [];
window._oirtrk.push(['set', 'puid', '12345']);
</script>
See the Global Custom Data Guide for more details.
Why remove the manual tracking?
- The SDK now automatically tracks on-site events
- Manual tracking may cause duplicate events
- Automatic tracking provides better timing and cross-tab coordination
Note: Removing the second script block is recommended but not required. The SDK will handle both cases gracefully.
Event not firing?
- Verify SDK is loaded and configured
- Check if the user meets the time threshold
- Ensure the event hasn't already fired in the current session
- Check browser console for errors
Event firing too early/late?
- The time threshold is configured in your dashboard
- Contact your account manager to adjust the threshold
- Installation Guide - Install and configure the SDK
- Custom Events Guide - Track custom business events
- Ecommerce Events - Ecommerce event tracking