Track Custom Events (React)

Track custom actions that your users perform

If you use an analytics tool, you likely track custom events to measure your users' in-app behavior. Use LogRocket.track() to make these events accessible in LogRocket.

LogRocket.track() accepts a single String argument:

LogRocket.track('Registered');

You can then search for sessions containing these events using a Custom Event filter in the LogRocket Dashboard:

You can optionally provide a second Object argument containing properties that will be associated with the event:

LogRocket.track('PurchaseComplete', {
   revenue: 42.99,
   productCategory: 'Clothing',
   productSku: 4887369299,
   couponApplied: true,
   customerSegments: ['aef34b', '97cb20']
});

Properties may be of type boolean, integer, float, or string. Arrays of primitives (boolean, integer, float, or string) are also supported.

There are a few limits to keep in mind when providing properties to LogRocket.track():

  • Property names must be under 100 characters.
  • A maximum of 2000 properties may be uploaded per session. Properties over this limit will not be recorded.

📘

'Revenue' Property

The 'revenue' property is a special property that you can use to pass data into our funnels. For more information, see here.