Ahoy is a first-party analytics library for Rails that tracks visits and events directly in your application's database.
The tool solves the problem of collecting analytics data without relying on third-party services. It automatically creates visits when users arrive at your site, capturing traffic source, location, technology details, and UTM parameters. Events can be tracked from Ruby controllers, JavaScript, or native mobile apps. Data is stored in your database by default, but the architecture supports customization for other data stores as your needs grow. The library includes built-in GDPR compliance options and can defer visit creation to JavaScript to filter out bots and users with cookies disabled.
Ahoy suits Rails applications where you want to own your analytics data and avoid external tracking services. It works well for projects that need basic visit and event tracking without the complexity of a dedicated analytics platform. The tool integrates naturally with Rails conventions, automatically attaching the current user to visits and providing a `current_visit` method for accessing visit data in controllers. You can prevent certain actions from creating visits, which is useful for API endpoints. The library also supports associating other models with visits through a `visitable` mixin, making it easy to track which visits led to conversions or other business events.
The project maintains active development with regular updates addressing user-reported issues and feature requests. Pull requests receive timely review and feedback from maintainers. The codebase shows consistent attention to edge cases, such as handling authentication frameworks beyond Devise and supporting multiple JavaScript bundlers. Documentation is comprehensive and includes detailed sections on geocoding setup and GDPR compliance options. The maintainers are responsive to questions and suggestions in issues, demonstrating engagement with the user community.