Description
Ahoy.js is a small JavaScript library for tracking visits and events on a website, and it works with any backend. When someone lands on a page, the library gives the visitor a visit token and a visitor token, then sends a POST request to your server with the referrer and landing page. The visit token expires after 4 hours, which starts a new visit, and the visitor token expires after 2 years, which makes it possible to count unique visitors and monthly active users. Your server can add details such as the IP address, user agent and logged-in user, and calculate the referring domain, search keyword, UTM campaign fields, location and browser type. Custom events are sent with a name, properties and a time, and the README suggests rejecting timestamps that do not match the server clock. Ahoy.js can also record page views, clicks, form submits and, in a deprecated form, changes, using their names and element details such as tag, id, class and text. It can be included with a script tag or installed with Yarn and imported. For Rails applications, the author points to the separate Ahoy gem.…
Highlights
- Tracks unique visitors and visits
- Custom events with names and properties
- Automatic page view, click and submit tracking
- Visit and visitor tokens with set expiry times
- Works with any backend, with a Rails gem available
Ratings & Reviews
No ratings yet
Be the first to rate Ahoy.js.
People also visit
Analytics
Lightweight analytics abstraction layer for tracking page views, custom events

Snowplow Javascript Tracker
Snowplow event tracker for client-side and server-side JavaScript
Aptabase
Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web apps
Ahoy.js FAQ
What is Ahoy.js?
A JavaScript library for visit and event tracking on a website, designed to work with any backend.
How does it count visitors?
Each visitor gets a visitor token that lasts 2 years, and each visit gets a visit token that expires after 4 hours, so a new visit starts after that.
How do I install it?
Download ahoy.js and include it on the page, or install it with Yarn and import it.
What does the server receive?
A POST to /ahoy/visits with the visit token, visitor token, referrer and landing page, and a POST to /ahoy/events for custom events.
Is it for Rails only?
No. The README says it works with any backend and points to the separate Ahoy gem for Rails apps.
What are the best Ahoy.js alternatives?
Popular alternatives to Ahoy.js include Ahoy, Analytics and Snowplow Javascript Tracker. See all Ahoy.js alternatives
.png?auto=compress&fit=max&w=128)
