title | tags | metaDescription | redirects | freshnessValidatedDate | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Report browser monitoring custom events and attributes |
|
How to report custom events and attributes with browser monitoring in New Relic. |
|
never |
You can use browser monitoring in New Relic to add custom events and attributes.
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 and any custom attribute names and values you capture along with it. The PageAction
event also contains any custom attributes you added to the PageView
event.
Add custom attributes to the PageView
event so you can query or filter your data to answer more questions about your application.
In order to report PageAction
events, verify these prerequisites:
<th>
<DoNotTranslate>**Comments**</DoNotTranslate>
</th>
</tr>
<td>
Your browser monitoring agent version must be [593 or higher](/docs/browser/new-relic-browser/installation-configuration/upgrading-browser-agent#checking).
</td>
</tr>
<tr>
<td>
Client browser version
</td>
<td>
To record `PageAction` events, the browser must [support cross-domain XHRs](/docs/browser/new-relic-browser/getting-started/compatibility-requirements#browser-types).
</td>
</tr>
<tr>
<td>
Max events per cycle
</td>
<td>
`PageAction` events are reported every 30 seconds, with a maximum of 120 events per 30-second harvest cycle, per browser. After the 120-event limit is reached, additional events are not captured for that cycle.
</td>
</tr>
<tr>
<td>
Event/attribute naming, data type, size
</td>
<td>
Ensure you follow [general requirements](/docs/insights/insights-data-sources/custom-data/data-requirements#general) around event/attribute naming syntax, data types, and size.
</td>
</tr>
**Requirement** |
---|
Agent version |
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).
The PageView
event is a default browser-reported event. You can add custom attributes to the PageView
event. Any custom attributes you add to the PageView
event are also automatically added to the PageAction
event.
There are two ways to add custom attributes to the PageView
event:
<Collapser id="custom-attribute-forward-apm" title="Forward custom attributes from APM data"
If you added custom attributes to the <InlinePopover type="apm" /> `Transaction` event via an APM agent, you can forward those custom attributes to the `PageView` event automatically:
1. Insert custom attributes by following the [agent-specific instructions](/docs/insights/insights-data-sources/custom-data/add-custom-attributes-apm-data).
2. Enable attribute forwarding in your agent configuration file:
<table>
<thead>
<tr>
<th style={{ width: "100px" }}>
Agent
</th>
<th>
Enable attribute forwarding
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Go
</td>
<td>
To enable attributes, add this to your config (disabled by default):
```go
cfg.BrowserMonitoring.Attributes.Enabled = true
```
Then add the attributes you want to include:
```go
cfg.BrowserMonitoring.Attributes.Include = []string{"request.*"}
```
</td>
</tr>
<tr>
<td>
Java
</td>
<td>
Add the [`attributes.enabled`](/docs/agents/java-agent/configuration/java-agent-configuration-config-file#cfg-browser-attributes-enabled) option in the `browser_monitoring` section and set it to `true`.
</td>
</tr>
<tr>
<td>
.NET
</td>
<td>
Add the [`<attributes enabled="true">`](/docs/agents/net-agent/installation-configuration/net-agent-configuration#browser-attributes) element as a child of the `browserMonitoring` element:
```xml
<configuration xmlns="urn:newrelic-config">
...
<browserMonitoring autoInstrument="true">
...
<attributes enabled="true">
...
</attributes>
</browserMonitoring>
...
</configuration>
```
If you are using [manual browser instrumentation](/docs/agents/net-agent/features/page-load-timing-net#manual_instrumentation) the attribute needs to be created before the `GetBrowserTimingHeader()` call.
</td>
</tr>
<tr>
<td>
Node.js
</td>
<td>
Add [`attributes: {enabled: true}`](/docs/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration#browser-debug-enabled) to the `browser_monitoring` section of your app's `newrelic.js` configuration file.
</td>
</tr>
<tr>
<td>
PHP
</td>
<td>
Add the [`newrelic.browser_monitoring.attributes.enabled`](/docs/agents/php-agent/attributes/enabling-disabling-attributes#cfg-browser-attributes-enabled) option and set it to `true`.
</td>
</tr>
<tr>
<td>
Python
</td>
<td>
Add the [`browser_monitoring.attributes.enabled`](/docs/agents/python-agent/installation-configuration/python-agent-configuration#cfg-browser-attributes-enabled) option and set it to `true`.
</td>
</tr>
<tr>
<td>
Ruby
</td>
<td>
Add the [`browser_monitoring.attributes.enabled`](/docs/agents/ruby-agent/installation-configuration/ruby-agent-configuration#browser_monitoring-attributes-enabled) option and set it to `true`.
</td>
</tr>
</tbody>
</table>
To see the default attributes of PageAction
and PageView
, see Browser events.
Here are some troubleshooting tips:
<th>
<DoNotTranslate>**Comments**</DoNotTranslate>
</th>
</tr>
<td>
If your custom attributes do not appear on `PageView` events, verify you are calling `setCustomAttribute` before the Load event on your page. If the custom attribute is called after the page load occurs, it will not be visible on `PageView`.
</td>
</tr>
<tr>
<td>
`PageAction` events
</td>
<td>
If your `PageAction` events do not appear when you query, review the [requirements](#requirements).
If the requirements are met, check that you're not using [reserved attribute names or invalid values](/docs/insights/new-relic-insights/adding-querying-data/inserting-custom-events-insights-api#limits).
</td>
</tr>
**Problem** |
---|
Custom attributes missing |