Send pageviews manually (manual mode)
Turn off the automatic pageview with data-manual and send pageviews yourself with privatus.pageview(), for example after reading an A/B test variant at runtime.
Add data-manual="true" to stop the automatic pageview when the page
loads:
html
<script defer src="https://privatusanalytics.com/js/pa.js" data-site="pa_YOURSITEID" data-manual="true"></script>
Then send pageviews when you decide:
js
privatus.ready(() => {
if (!document.body.classList.contains('preview')) {
privatus.pageview({ props: { logged_in: isLoggedIn } })
}
})
Manual mode only turns off the first automatic pageview. SPA
navigation tracking still runs. Add data-spa="off" too if you want full
control:
html
<script defer src="https://privatusanalytics.com/js/pa.js" data-site="pa_YOURSITEID"
data-manual="true" data-spa="off"></script>
When to use it#
- You want to add properties to the first pageview that aren't known until later (for example, after reading an A/B test variant).
- Some pages shouldn't count based on runtime logic (previews, staff sessions).
- Your router needs pageviews at a moment the History API doesn't reflect
(after data loads, or on modal "pages" that change the URL with
replaceState).
privatus.pageview() always records the current location.href, so
update the URL before calling it.