app/controllers or a service object · open source (MIT) · ask in plain English

Add analytics to Ruby on Rails.

smolanalytics gives a Rails app two tracking paths: server-side events (signups, purchases, jobs) posted from your controllers and models, and a browser snippet in your layout that autocaptures pageviews and clicks. You ask the numbers in plain English and get deterministic reports, not dashboards you have to assemble.

app/controllers or a service object
require "net/http"
require "json"

uri = URI("https://YOUR-INSTANCE/v1/events")
Net::HTTP.post(
  uri,
  { name: "signup", distinct_id: current_user.id.to_s, properties: { plan: "pro" } }.to_json,
  "Authorization" => "Bearer WRITE_KEY",
  "Content-Type" => "application/json"
)

# Web autocapture: put these two tags in app/views/layouts/application.html.erb <head>
# <script src="https://YOUR-INSTANCE/sdk.js"></script>
# <script>smolanalytics.init("WRITE_KEY", { host: "https://YOUR-INSTANCE" })</script>

wrap the POST in an ActiveJob so a slow request never blocks your controller. the two script tags go in application.html.erb.

how do I add analytics to ruby on rails?

smolanalytics gives a Rails app two tracking paths: server-side events (signups, purchases, jobs) posted from your controllers and models, and a browser snippet in your layout that autocaptures pageviews and clicks. You ask the numbers in plain English and get deterministic reports, not dashboards you have to assemble.

The server side is the honest part of a Rails app: the model callback that fires when a subscription actually charges, the controller action that confirms a checkout. Post those to /v1/events with a Bearer write key and a distinct_id, batch them into a background job, and you have a truth source that doesn't depend on the browser. Add identify(user.id) in the layout snippet after login and your web sessions stitch to the same person.

Rails apps drown in half-finished analytics gems. smolanalytics is one Go binary you self-host (MIT) or run hosted from $29/mo, and every number you ask for is a computed report with a CI test proving it can't be hallucinated. Ask it from the dashboard bar or from your editor over MCP: "how many pro signups converted from the pricing page last week."

Honest pricing: 14-day full trial, no credit card. Then Solo $29/mo, never metered on seats or sites. Overage is $5/million with an emailed receipt, the dashboard never locks, and self-hosting the single Go binary is free forever (MIT).

Add analytics to Ruby on Rails tonight.

One snippet, or one endpoint. Tomorrow morning the verdict tells you which part of the funnel to fix.

questions

How do I add analytics to Ruby on Rails?
smolanalytics gives a Rails app two tracking paths: server-side events (signups, purchases, jobs) posted from your controllers and models, and a browser snippet in your layout that autocaptures pageviews and clicks. You ask the numbers in plain English and get deterministic reports, not dashboards you have to assemble.
Do I need a cookie banner?
Not in cookieless mode. smolanalytics can run without storing anything on the device, so there is no consent banner to add. You still get visitors, referrers, funnels, retention, and paths, and AI-assistant referrals (chatgpt.com, claude.ai, perplexity.ai) show up as their own channel.
Is it enough for a real product, or just page counts?
It does funnels, retention, paths, cohorts, and a daily verdict on what to fix, from the same events, and you ask it in plain English. It deliberately skips session replay, feature flags, and experiments. If you want a straight answer on what to fix, that you own and can self-host free, it fits.

keep reading