# Add Privatus Analytics to Inertia.js

> Add cookieless analytics to an Inertia.js app with one snippet in the server-side root template, so every page visit is counted once.

Put the snippet in the server-side root template, not in a page component.
With Laravel that is `resources/views/app.blade.php`, in `<head>`:

```blade
@production
  <script defer src="https://privatusstats.com/js/pa.js" data-site="pa_YOURSITEID" data-modules="engage,auto,vitals,clicks,ask"></script>
@endproduction
```

With Rails use `app/views/layouts/application.html.erb` and
`<% if Rails.env.production? %>` instead. Inertia leaves head elements that
are in the root template alone, so the script loads once.

Don't render the script through Inertia's `<Head>` component. It manages
head elements per page, which is the wrong place for a site-wide tracker.

Inertia visits use `history.pushState`, which the tracker follows with its
default `data-spa="auto"`, so each visit is one page view. See
[single-page apps](/docs/tracker/spa) and the
[Laravel](/docs/install/laravel) page.
