actionText (Browser SPA API)

newrelic.interaction().actionText(string $value)
Sets the text value of the HTML element that was clicked to start a browser interaction.

Requirements

Agent version nr-1099 or higher.

Single-page app (SPA) calls require New Relic Browser Pro.

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 Insights 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 in New Relic Browser and the BrowserInteraction event type within New Relic Insights. 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

$value

string

The text value of the HTML element that represents the action that started the interaction.

Return value(s)

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

Example(s)

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

For more help

Recommendations for learning more: