Manual Pageview Control
The SealMetrics tracker automatically tracks pageviews on page load and SPA navigation. However, there are scenarios where you need manual control over when pageviews are recorded.
Automatic Behavior
By default, the tracker:
- Tracks initial pageview when the script loads
- Tracks SPA navigation via History API (
pushState,replaceState,popstate)
For most websites, this is all you need.
When to Use Manual Control
1. Hash-Based Routing
If your SPA uses hash-based routing (#/page instead of /page), you need to manually trigger pageviews:
window.addEventListener('hashchange', function() {
if (typeof sealmetrics !== 'undefined') {
sealmetrics();
}
});
2. Multi-Step Forms
Track each step of a multi-step form as a separate pageview:
function goToStep(stepNumber) {
// Your form logic...
// Track as pageview with content group
if (typeof sealmetrics !== 'undefined') {
sealmetrics({ group: 'checkout-step-' + stepNumber });
}
}
3. Modal/Tab Navigation
Track when users open significant modals or tabs:
function openProductModal(productId) {
// Your modal logic...
// Track modal open as pageview
if (typeof sealmetrics !== 'undefined') {
sealmetrics({ group: 'product-modal' });
}
}
Tracking Events Without Pageviews
When you want to track an event (conversion or microconversion) without recording an additional pageview, simply call the event method directly:
// Track a microconversion (no pageview recorded)
sealmetrics.micro('video_play', {
video_id: 'demo-2025'
});
// Track a conversion (no pageview recorded)
sealmetrics.conv('lead', 0, {
form_name: 'contact'
});
Events (conv() and micro()) never create additional pageviews. Only sealmetrics() creates pageviews.
Content Grouping with Manual Pageviews
When calling manual pageviews, you can set the content group:
// Navigate to checkout step 2
sealmetrics({ group: 'checkout' });
// Navigate to product detail
sealmetrics({ group: 'product' });
Best Practices
- Don't duplicate pageviews — If automatic tracking works, don't call
sealmetrics()manually - Use content groups — When calling manual pageviews, set meaningful groups
- Events don't need pageviews —
conv()andmicro()are standalone events - Check tracker exists — Always use
typeof sealmetrics !== 'undefined'
Related Documentation
- SPA Support - Automatic SPA tracking
- Content Grouping - Page categorization
- Microconversions - Event tracking