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

## Syntax

```js
newrelic.interaction().save()
```

Ensures a SPA browser interaction will be saved when it ends.

## Requirements

-   Browser Pro+SPA agent (v963 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 method ensures a browser interaction will be saved when it ends. Normally an interaction is only saved and sent to New Relic if it is the initial page load or if it is a route change subject to the [default heuristic](https://docs.newrelic.com/docs/browser/single-page-app-monitoring/use-spa-data/spa-data-collection#browser-interaction). You must call this method to override this behavior and guarantee the interaction will be recorded.

## Return values

This method returns the same API object created by `interaction()`, which is associated with a [`BrowserInteraction` event](https://docs.newrelic.com/docs/insights/explore-data/attributes/browser-default-attributes-insights#browserinteraction-attributes).

## Examples

```js
window.addEventListener('scroll', () => {
  if (atBottomOfPage()) {
    newrelic.interaction() // Start monitoring this interaction.
      .setName('loadNextPage') // Set name of interaction.
      .save(); // Ensure that this interaction will be saved as a BrowserInteraction event when it ends, even if URL change and DOM modification did not occur.
    loadNextPage(); // Start loading the next page.
  }
});
```
