# Install on Rails

> Add the tag to the application layout head, and let Turbo navigation be counted automatically.

Section: Installation guides  
Canonical page: https://statsy.co/docs/install/rails  
Last updated: 2026-09-15

Rails renders almost everything through one layout. That is where the tag belongs.

## Where it goes

Open `app/views/layouts/application.html.erb` and paste the tag inside `<head>`.

```erb
<head>
  <%= csrf_meta_tags %>
  <%= stylesheet_link_tag "application" %>
  <script defer data-website-id="ws_XXXXXXXX" data-domain="yourstartup.com" src="https://statsy.co/js/script.js"></script>
</head>
```

Paste it as plain HTML. `javascript_include_tag` is for assets in your own pipeline and would not carry the `data-*` attributes the script reads.

## Confirm it works

Deploy and open the site, then check **Live**. Click an internal link: Turbo navigates with the History API, so each page is counted without a full reload and without extra code.

## Turbo keeps the script loaded

Turbo Drive replaces the body and merges the head, so the script is loaded once and stays alive across navigations. That is the behaviour Statsy wants, so do not add `data-turbo-track="reload"` to the tag: forcing a full reload on every page would throw away the session state the script keeps in the tab. If you render a second layout for sign-in or mailers, add the tag there too if those pages should be measured.

Previous: [Install on Django](https://statsy.co/docs/install/django)  
Next: [Install on Lovable](https://statsy.co/docs/install/lovable)