---
title: setPageViewName
source: https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setpageviewname
---

## Syntax

```js
newrelic.setPageViewName(string $name[, string $host])
```

Groups page views to help URL structure or to capture the URL's routing information.

## Requirements

-   Browser Lite, Pro, or Pro+SPA agent (v593 or higher)
-   If you're installing the browser agent via npm and building a custom agent with selected features, you must enable at least one feature when creating the `Agent` instance. For example, add the following in the`features` array:

    ```js
    import { Metrics } from '@newrelic/browser-agent/features/metrics'

    const options = {
      info: { ... },
      loader_config: { ... },
      init: { ... },
      features: [
        Metrics
      ]
    }
    ```

    For more information, see the [npm browser installation documentation](https://www.npmjs.com/package/@newrelic/browser-agent#new-relic-browser-agent).

## Description

Customized page names can help you more effectively group your page views if your URL structure does not provide useful groupings or if the browser agent doesn't capture the part of the URL where routing information is stored. When querying the `PageView` [event](https://docs.newrelic.com/docs/using-new-relic/data/understand-data/new-relic-data-types#event-data), the custom name will be exposed as the `browserTransactionName` attribute. The custom name will also be visible in the browser monitoring UI.

To use a customized [page view name](https://docs.newrelic.com/docs/browser/new-relic-browser/additional-standard-features/page-views-insights-your-sites-popularity) instead of the page URL, format the name as a slash-delimited string. Make this call before the `window load` event fires in order for it to appear correctly.

> #### 💡 TIP
>
> This API call applies to data in standard page views in browser and the [`PageView`](https://docs.newrelic.com/docs/insights/insights-data-sources/default-data/browser-default-events-attributes-insights#browser-attributes-table) event. To set a custom name for SPA page views and the `BrowserInteraction` event, see [SPA: setName](https://docs.newrelic.com/docs/browser/new-relic-browser/browser-agent-spa-api/spa-set-name). Using both calls together is recommended.

## Parameters

| Parameter        | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `$name` _string_ | Required. The page name you want to use. Use alphanumeric characters.                                                                                                                                                                                                                                                                                                                                                                                                            |
| `$host` _string_ | Optional. Default is `http://custom.transaction`. Typically set `host` to your site's domain URI. To further group these custom transactions, provide a custom `host`. Otherwise, the page views will be assigned the default domain `custom.transaction`. Segments within the name must be explicitly added to your [URL allow list settings](https://docs.newrelic.com/docs/browser/new-relic-browser/configuration/group-browser-metrics-urls) if they do not already appear. |

## Examples

```js
newrelic.setPageViewName('/login')
// Or
newrelic.setPageViewName('/login', 'https://www.myapp.com')
```
