You can use browser monitoring in New Relic to add custom events and attributes.
Custom attributes
Add custom attributes to all browser events so you can query or filter your data to answer more questions about your application.
Custom events
Use the browser API's recordCustomEvent
method to capture any event with custom attribution.
Page actions
Use the browser API's addPageAction
call to capture events, actions, route changes, or any end-user interactions with your application. The addPageAction
call adds an event named PageAction
that contains the action name, metadata relating to your page and any custom attribute names and values you capture along with it.
Prerequisites
In order to report Custom
events, verify these prerequisites:
Requirement | Comments |
---|---|
Agent version | Your browser monitoring agent version must be 1.277.0 or higher. |
Client browser version | To record |
Events per cycle |
|
Event/attribute naming, data type, size | Ensure you follow general requirements around event/attribute naming syntax, data types, and size. |
In order to report PageAction
events, verify these prerequisites:
Requirement | Comments |
---|---|
Agent version | Your browser monitoring agent version must be 593 or higher. |
Client browser version | To record |
Events per cycle |
|
Event/attribute naming, data type, size | Ensure you follow general requirements around event/attribute naming syntax, data types, and size. |
Create custom events
To create a custom
event:
- Ensure the browser agent is installed for your app.
- Call the
newrelic.recordCustomEvent
function in the relevant part of your application's JavaScript. - Wait a couple minutes for the application to run and report relevant
custom
events under the eventType you specified. - Run a NRQL query of the event that includes the
eventType
attribute you used to capture the event (and any associated attributes you sent along with the event).
- For example, if you sent a
custom
event with aneventType
ofFoo
and an attribute ofbar: 123
, you could run a query like this:SELECT * FROM Foo WHERE bar = 123
Create PageAction events
To create a PageAction
event:
- Ensure the browser agent is installed for your app.
- Call the
newrelic.addPageAction
function in the relevant part of your application's JavaScript. - Wait a couple minutes for the application to run and report relevant
PageAction
events. - Run a NRQL query of the
PageAction
event that includes theactionName
attribute you used to capture the event (and any associated attributes you sent along with the action).
- For example, if you sent a
PageAction
event with anactionName
ofFoo
and an attribute ofbar: 123
, you could run a query like this:SELECT * FROM PageAction WHERE actionName = 'Foo' AND bar = 123
Add custom attributes to Browser events
You can add custom attributes to all Browser events. Any custom attributes you add using the setCustomAttribute
API will be added to all events captured.
There are two ways to add custom attributes:
Important considerations and best practices include:
You should aim to limit the total number of custom event types to approximately five. Custom event types are meant to be used to encapsulate high-level categories. For example, you might create an event type called Gestures that contains many events with various purposes.
Avoid using event type to name custom events. Create event types to house a category of data and use attributes within that category to differentiate events. While you can create numerous custom events, it's important to keep your data manageable by limiting the number of event types reported.
Included Attribution
Custom browser events are decorated with the following attributes intended to help you understand the context of the browser environment when the event occurred:
Troubleshooting
Here are some troubleshooting tips:
Problem | Comments |
---|---|
Custom attributes missing | If your custom attributes do not appear on |
| If your If the requirements are met, check that you're not using reserved attribute names or invalid values. |
| If your If the requirements are met, check that you're not using reserved attribute names or invalid values. |