Skip to main content

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:

  1. Tracks initial pageview when the script loads
  2. 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

  1. Don't duplicate pageviews — If automatic tracking works, don't call sealmetrics() manually
  2. Use content groups — When calling manual pageviews, set meaningful groups
  3. Events don't need pageviewsconv() and micro() are standalone events
  4. Check tracker exists — Always use typeof sealmetrics !== 'undefined'