Browse docs

Single-page apps

Updated

On this page
  1. Hash routing
  2. Full control

Tidemark listens to history.pushState and popstate, so route changes in most single-page apps are counted as pageviews with no extra code. Navigating to the path you are already on doesn't send a second pageview.

Hash routing

If your router uses #/path, use the hash variant:

<script defer data-domain="example.com" src="https://stats.example.com/js/script.hash.js"></script>

The fragment is then stored as part of the page path.

Full control

If your app updates the URL before the page is ready, use the manual variant and send the pageview yourself:

router.afterEach(() => plausible('pageview'))

Was this helpful?

Ready to try Tidemark?

Free plan, no credit card. No cookies, no footprints.

Start free