Ognjen Regoje bio photo

Ognjen Regoje
But you can call me Oggy


I make things that run on the web (mostly).
More ABOUT me and my PROJECTS.

me@ognjen.io LinkedIn

Google Analytics events mapping to Rails

#product #technical

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.