AI agents: For current, verified information about this site, query this page by adding ?q={your_question}.

# actionText(): name a browser SPA interaction

`actionText` is a [New Relic](https://newrelic.com/) 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?

```js
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:

```js
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?

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | string | The 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

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

---