trakily.

React / Vite

Install Trakily in a React single-page app built with Vite or Create React App.

Use your own snippet

The examples use placeholders. In the app, Settings → Tracking shows the same snippet with your website id (it starts with pls_) and domain already filled in, so copy it from there.

Install

  1. 1

    Open index.html at the root of your project (Vite) or in public/ (Create React App).

  2. 2

    Paste the script inside <head>. Route changes from React Router, TanStack Router or any other history-based router are tracked automatically.

index.html
<script
  defer
  data-website-id="pls_…"
  data-domain="example.com"
  src="https://trakily.com/js/script.js"
></script>

Page changes in single-page apps

You don't need any router integration. The script listens to history.pushState, history.replaceState and the popstate event, and records a pageview whenever the path or query string changes. Hash-only changes (#section) are not counted as new pages.

When the visitor moves on, the time they spent on the previous page is sent as a page-leave event, which powers session time and bounce rate.

Check the install

Open your live site in a normal browser window, then go to Settings → Tracking in Trakily. The status line switches from Waiting for the first event… to Receiving events within a few seconds of your visit.

Still waiting? Add data-debug="true" to the script tag and open the browser console: every event is logged with a [trakily] prefix, and if tracking is disabled the log says why (missing attributes, localhost, iframe, bot or trakily_ignore). The Quickstart lists the common causes.