newrelic.com

Command Palette

Search for a command to run...

actionText(): name a browser SPA interaction

Last updated: 8/14/2026

actionText(): name a browser SPA interaction

actionText is a New Relic SPA (single page application) API method that sets the text value of the HTML element clicked to start a browser interaction. The value is exposed as the actionText attribute on the BrowserInteraction event.

What is the exact syntax?

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

What browser agent version is required?

Browser Pro+SPA agent v1099 or higher.

If you are installing the browser agent via npm and building a custom agent with selected features, you must enable the spa feature when creating the Agent instance:

import { Spa } from '@newrelic/browser-agent/features/spa';

const options = {
  info: { ... },
  loader_config: { ... },
  init: { ... },
  features: [
    Spa
  ]
}

What does actionText do?

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

The agent automatically attempts to determine the text value of the clicked HTML element, but this automatic detection applies only to <a>, <button>, and <input> elements. The actionText API covers cases where automatic detection is not sufficient or accurate.

This API call applies to SPA page views and the BrowserInteraction event type. To set a custom name for standard page views and the PageView event type, use setPageViewName. Using both calls together is recommended.

What are the parameters?

ParameterTypeDescription
$valuestringThe text value of the HTML element that represents the action that started the interaction.

What does actionText return?

The method returns the same API object created by interaction(), so calls can be chained.

Example: label a route change in a single-page app

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