---
title: actionText (SPA API)
source: https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/actiontext
---

## Syntax

```js
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 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. In the `features` array, add the following:

    ```js
    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](https://www.npmjs.com/package/@newrelic/browser-agent#new-relic-browser-agent).

## 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`](https://docs.newrelic.com/docs/insights/explore-data/attributes/browser-default-attributes-insights#interaction-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.

> #### 💡 TIP
>
> This API call applies to data in [SPA page views](https://docs.newrelic.com/docs/browser/single-page-app-monitoring/get-started/introduction-single-page-app-monitoring) in browser and the [`BrowserInteraction`](https://docs.newrelic.com/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`](https://docs.newrelic.com/docs/browser/new-relic-browser/browser-agent-spa-api/set-pageview-name). Using both calls together is recommended.

## Parameters

| Parameter         | Description                                                                                 |
| ----------------- | ------------------------------------------------------------------------------------------- |
| `$value` _string_ | The text value of the HTML element that represents the action that started the interaction. |

## Return values

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

## Examples

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