Analytics
If you're using an analytics service like Google Analytics, Umami, SimpleAnalytics, etc. you can add its tag to app/views/layouts/html_head/_analytics.html.erb, and this will achieve three things:
- It will add your analytics tag to all pages
- Without cluttering the main layout (
app/views/layouts/application.html.erb) - It's instantly reusable by other layouts in your app (like
app/views/layouts/devise.html.erb) maintaining a single source of truth for all your analytics tags
First-party event tracking (opt-in)
For simple first-party event trails on your own models — "this user logged in from Spain", "this license was activated from this IP" — uncomment gem "footprinted" in the Gemfile: it gives any model a has_trackable :visits-style API with IP geolocation built in. See the footprinted README.
If you self-host Umami analytics, the umami-ruby gem wraps its API if you ever need to query stats from Ruby.