// the find
ankane/ahoy
Simple, powerful, first-party analytics for Rails
Ahoy is a Rails gem for first-party visit and event analytics, with JS/native-app tracking that posts into the same backend. It's for teams who want basic product analytics (visits, events, UTM/referrer data) living in their own Postgres/MySQL/Mongo database instead of shipping behavioral data to Segment or Mixpanel.
The data store abstraction (BaseStore/DatabaseStore with track_visit/track_event/geocode/authenticate hooks) means you can start writing to your own DB and later redirect the same instrumentation calls to Kafka or Kinesis without touching call sites. The GDPR tooling is genuinely built out, not a checkbox: IP masking uses the same last-octet/80-bit scheme as Google Analytics, and anonymity sets let you drop cookies entirely while still grouping requests. The visitable association turns attribution into a plain SQL join (Order.joins(:ahoy_visit).group(:referring_domain)) instead of needing a separate attribution service. Tracking exceptions are rescued by default so a broken analytics call can't take down a request.
Data retention is a copy-pasted find_in_batches snippet in the README, not a scheduled job - nothing in the gem enforces deletion, so visit/event tables grow unbounded unless you wire up your own cron. Funnels are three sequential pluck/where queries chained manually; there's no real funnel engine with conversion windows or branching, so it falls apart past 2-3 steps. Forecasting, anomaly detection, and recommendations are all pushed out to separate single-maintainer gems from the same author (Prophet, AnomalyDetection.rb, Breakout, Disco), so anything beyond raw counts means pulling in and trusting several more small dependencies. There's no built-in rate limiting on the /ahoy/visits and /ahoy/events JS endpoints - Rack::Attack config is left entirely to you, so a fresh install is open to abuse until you add it.