Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

1.3 KB
Raw Blame
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Plausible Playwright tests</title>
    <script async src="/tracker/js/plausible.hash.local.manual.js"></script>
    <script>
      window.plausible =
        window.plausible ||
        function () {
          ;(window.plausible.q = window.plausible.q || []).push(arguments)
        }
    </script>
  </head>

  <body>
    <a id="about-us-hash-link" href="#about">About us</a>
    <a id="home-hash-link" href="#home">Home</a>

    <div>
      <p id="page-title">Home</p>
    </div>

    <script>
      const titleNode = document.getElementById('page-title')

      function updateContent() {
        if (location.hash === '#about') {
          titleNode.innerHTML = 'About us'
          window.plausible('pageview', { u: 'http://localhost:3000/#about-us' })
        } else {
          titleNode.innerHTML = 'Home'
          window.plausible('pageview', { u: 'http://localhost:3000/#home' })
        }
      }

      window.plausible('pageview', { u: 'http://localhost:3000/#home' })
      window.addEventListener('hashchange', updateContent)
    </script>
  </body>
</html>