Ognjen Regoje bio photo

Ognjen Regoje

I make things that run on the web (mostly).
More /ABOUT me.

me@ognjen.io Twitter LinkedIn Github

Google Analytics events mapping to Rails

I keep having to revisit this so I’m hoping that by writing it down my retention will increase from seconds to at least a day.

When creating Google Analytics events within a Rails app (in fact in any MVC-like framework) the action responds to the action name, the category corresponds to the controller name and the label can loosely correspond to where the action has taken place.

So, for instance if you had a lead capturing form you could send an event like this:

gtag('event', "Create", {
  'event_category': "Leads",
  'event_label': "Homepage",
  'value': 0

You could then swap the label to different landing page names for instance.

#product #technical