---
title: nrAddDomainSubstitution
source: https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/domain-management/nradddomainsubstitution
---

## Syntax

```js
  nrAddDomainSubstitution(nr as object, pattern as String, subs as String) as Void
```

## Description

-   Add a matching pattern for the domain attribute and substitute it by another string.
    -   Every time an event or metric is generated with a domain attribute, tha agent will check if it matches a regex and will apply the specified substitution.
-   If no pattern is set, it will use the URL domain unchanged.
    -   It applies to all events and metrics containing the "domain" attribute.

## Arguments

| Arguments | Description             |
| --------- | ----------------------- |
| `nr`      | New Relic Agent object. |
| `pattern` | Regex pattern.          |
| `subs`    | Substitution string.    |

## Return

Nothing.

## Example

```js
  	nrAddDomainSubstitution(nr, "^.+\.my\.domain\.com$", "mydomain.com")
```
