Docs » Create custom events

Create custom events πŸ”—

Create custom events to capture meaningful metrics about customer journeys and user behavior on your site. Custom events support filtering by tags and the ability to add custom attributes.

How custom events can add value to your organization πŸ”—

Splunk RUM automatically collects metrics about page loads, errors, and core web vitals. Sometimes, you need custom logic to capture a specific workflow that is important to your organization to understand.

Use case πŸ”—

Suppose you are an online retailer. A meaningful custom event for your business might be understanding behavior around conversion rates and why users drop off and don’t finish a checkout workflow. You might also want to understand where users are stagnating in your application. You can create a custom event to discover which events precipitate an unsuccessful customer journey. Perhaps users are stopped by an error in your checkout workflow, or are unable to enter a promo code. Custom events provide the opportunity for you to see a unique perspective on your data driven by the questions that matter most to you.

Create a custom event πŸ”—

The following examples show how to create a custom event for browser, Android, and iOS applications.

To create a custom event, first declare the tracer, and next define the custom event.

You can declare the tracer through either CDN or NPM. You need to declare the tracer only once. For more information on the difference between CDN and NPM, see Instrument your web application for Splunk RUM.

The following example shows how to initialize the tracer and create a custom event using the NPM package:

import {trace} from '@opentelemetry/api'

const tracer = trace.getTracer('appModuleLoader');
const span = tracer.startSpan('test.module.load', {
attributes: {
      '': 'test.module.load'
// time passes

Next steps with custom events πŸ”—

For examples, dashboards, and metrics related to custom events see:

Advanced instrumentation πŸ”—

For more information on advanced instrumentation, see: