New: Free plan is live 7 August 2026 · View changelog →
Antlytics logoAntlytics

Add Antlytics to Ruby on Rails

Prerequisites

  • An Antlytics account (sign up free)
  • Your tracking ID from Settings → Tracking Snippet in your Antlytics dashboard

Install the snippet

Open app/views/layouts/application.html.erb and paste the snippet just before the closing </head> tag:

<%# app/views/layouts/application.html.erb %>
<!DOCTYPE html>
<html>
<head>
  <title><%= content_for?(:title) ? yield(:title) : "My App" %></title>
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <%= csrf_meta_tags %>
  <%= csp_meta_tag %>
  <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
  <%= javascript_importmap_tags %>

  <script
  defer
  src="https://www.antlytics.com/tracker.js"
  data-tracking-id="YOUR-SITE-ID"
  data-api-host="https://www.antlytics.com"
></script>
</head>
<body>
  <%= yield %>
</body>
</html>

Note: Replace YOUR-SITE-ID with the tracking ID from your Antlytics dashboard.

Hotwire / Turbo

If your app uses Hotwire Turbo Drive, Turbo replaces page content without full reloads. The hosted tracker’s History API patches and popstate listener capture Turbo navigations, so pageviews are recorded correctly.

Verify installation

  1. Visit your site in a browser.
  2. Open your Antlytics dashboard → Overview.
  3. Your visit should appear within a few seconds.

If data does not appear after a few minutes, check the troubleshooting guide.

Optional: First-party proxy

To avoid ad blockers, set up a first-party proxy on your own domain.

Need help?

Email support@antlytics.com with your site ID and page URL.

Something missing? Get in touch and we will update these docs.