Skip to content

Latest commit

 

History

History
285 lines (227 loc) · 11 KB

report-browser-monitoring-custom-events-attributes.mdx

File metadata and controls

285 lines (227 loc) · 11 KB
title tags metaDescription redirects freshnessValidatedDate
Report browser monitoring custom events and attributes
Insights
Event data sources
Custom events
How to report custom events and attributes with browser monitoring in New Relic.
/docs/telemetry-data-platform/custom-data/custom-events/report-browser-monitoring-custom-events-attributes
/docs/insights/new-relic-insights/adding-querying-data/inserting-custom-events-javascript-browser-api
/docs/insights/new-relic-insights/adding-querying-data/inserting-custom-events-browser-agent-api
/docs/insights/new-relic-insights/adding-querying-data/inserting-custom-events-browser
/docs/insights/new-relic-insights/adding-querying-data/inserting-custom-events-insights-javascript-api
/docs/insights/new-relic-insights/adding-querying-data/inserting-custom-events-attributes-insights-javascript-api
/docs/insights/new-relic-insights/custom-events/inserting-custom-events-attributes-insights-javascript-api
/docs/insights/explore-data/custom-events/insert-browser-custom-events-attributes-insights-javascript-api
/docs/insights/explore-add-data/custom-events/insert-browser-custom-events-attributes-insights-javascript-api
/docs/insights/insights-data-sources/custom-events/insert-browser-custom-events-attributes-insights-javascript-api
/docs/insights/insights-data-sources/custom-data/insert-browser-custom-events-attributes-insights-javascript-api
/docs/insights/insights-data-sources/custom-data/insert-via-new-relic-browser
/docs/insights/insights-data-sources/custom-data/insert-data-via-new-relic-browser
/docs/insights/insights-data-sources/custom-data/insert-custom-data-new-relic-browser-agent
/docs/insights/event-data-sources/custom-events/report-browser-monitoring-custom-events-attributes
never

You can use browser monitoring in New Relic to add custom events and attributes.

Page actions and views [#overview]

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.

Prerequisites [#requirements]

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

Create PageAction events [#creating-pageactions]

To create a PageAction event:

  1. Ensure the browser agent is installed for your app.
  2. Call the newrelic.addPageAction function in the relevant part of your application's JavaScript.
  3. Wait a couple minutes for the application to run and report relevant PageAction events.
  4. Run a NRQL query of the PageAction event that includes the actionName attribute you used to capture the event (and any associated attributes you sent along with the action).

Add custom attributes to PageView event [#custom-attributes]

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:

Use setCustomAttribute browser API call} > To add a custom attribute to the `PageView` event via the browser agent, use the [`setCustomAttribute`](/docs/browser/new-relic-browser/browser-agent-spa-api/newrelicsetcustomattribute-browser-agent-api) browser API call. This allows you to capture an attribute to be annotated on any `PageAction` 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>

PageAction and PageView attributes [#default-attributes]

To see the default attributes of PageAction and PageView, see Browser events.

Troubleshooting

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