Skip to content

Files

Latest commit

Jun 26, 2024
ae51cf7 · Jun 26, 2024

History

History
95 lines (73 loc) · 3.06 KB

File metadata and controls

95 lines (73 loc) · 3.06 KB
title type shortDescription tags metaDescription redirects freshnessValidatedDate
actionText (SPA API)
apiDoc
Sets the text value of the HTML element that was clicked to start a browser interaction.
Browser
Browser monitoring
Browser agent and SPA API
SPA API call with browser to set the name and trigger of a browser interaction that is not a route change or URL change.
/docs/browser/new-relic-browser/browser-agent-spa-api
/docs/browser/new-relic-browser/browser-agent-spa-api/actiontext-browser-spa-api
never

Syntax

newrelic.interaction().actionText(string $value)

Sets the text value of the HTML element that was clicked to start a browser interaction.

Requirements

  • Browser Pro+SPA agent (v1099 or higher)

  • If you're using npm to install the browser agent, you must enable the spa feature when instantiating the BrowserAgent class. In the features array, add the following:

    import { Spa } from '@newrelic/browser-agent/features/spa';
    
    const options = {
      info: { ... },
      loader_config: { ... },
      init: { ... },
      features: [
        Spa
      ]
    }

    For more information, see the npm browser installation documentation.

Description

This SPA monitoring method sets the text value of the HTML element that was clicked to start a browser interaction. The value will be exposed as the actionText attribute in the BrowserInteraction event.

NOTE: The agent automatically attempts to determine the text value of the HTML element that was clicked. This applies only to <a>, <button>, and <input> elements. The actionText API can be used in cases where this is not sufficient or accurate.

This API call applies to data in [SPA page views](/docs/browser/single-page-app-monitoring/get-started/introduction-single-page-app-monitoring) in browser and the [`BrowserInteraction`](/docs/insights/insights-data-sources/default-data/browser-default-events-attributes-insights#browserinteraction-attributes) event type. To set a custom name for standard page views and the **`PageView`** event type, see [`setPageViewName`](/docs/browser/new-relic-browser/browser-agent-spa-api/set-pageview-name). Using both calls together is recommended.

Parameters

  <th>
    Description
  </th>
</tr>
Parameter
`$value`
    _string_
  </td>

  <td>
    The text value of the HTML element that represents the action that started the interaction.
  </td>
</tr>

Return values

This method returns the same API object created by interaction().

Examples

document.getElementById('subscribe').addEventListener('submit', () => {
    newrelic.interaction().actionText('Create Subscription');
    createSubscription();
});