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 theBrowserAgent
class. In thefeatures
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.
Tip
This API call applies to data in SPA page views in browser and the BrowserInteraction
event type. To set a custom name for standard page views and the PageView
event type, see setPageViewName
. Using both calls together is recommended.
Parameters
Parameter | Description |
---|---|
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
document.getElementById('subscribe').addEventListener('submit', () => { newrelic.interaction().actionText('Create Subscription'); createSubscription();});