---
title: Filter sensitive URL content
description: Sanitize sensitive URL content before Session Replay and Heatmaps record it.
product: session-replay
lang: en
last_updated: 2026-11-04
token_estimate: 808
---
# Filter sensitive URL content

Configure `ugcFilterRules` to replace sensitive user-generated content in URLs before the SDK records URLs in replays and heatmaps. Use [web masking settings](https://amplitude.com/docs/session-replay/manage-privacy-settings-for-session-replay) to protect page text and form inputs.

> For AI agents: a documentation index is available at [/docs/llms.txt](/docs/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

1. Identify URLs that contain sensitive user IDs, company names, query parameters, or dynamic path segments.
2. Choose selectors and descriptive replacement URLs using the [UGC Filter Rules reference](https://amplitude.com/docs/session-replay/ugc-filter-rules).
3. Put specific rules before general rules. The SDK uses the first matching rule.
4. Add the rules to `interactionConfig` during SDK initialization and set `enabled: true`.

## Configure UGC Filter Rules

Configure UGC Filter Rules as part of the `interactionConfig` when initializing Session Replay. The Standalone SDK, the [Browser SDK plugin](https://amplitude.com/docs/sdks/session-replay/session-replay-plugin), and the `sessionReplay` options of the [Unified SDK](https://amplitude.com/docs/sdks/analytics/browser/browser-unified-sdk/get-started) all accept the same `interactionConfig` object.

#### Plugin

```javascript
import * as amplitude from "@amplitude/analytics-browser";
import { sessionReplayPlugin } from "@amplitude/plugin-session-replay-browser";

amplitude.add(
  sessionReplayPlugin({
    interactionConfig: {
      enabled: true,
      ugcFilterRules: [
        {
          selector: "https://example.com/user/*/profile",
          replacement: "https://example.com/user/USER_ID/profile",
        },
      ],
    },
  }),
);
amplitude.init("AMPLITUDE_API_KEY");
```

#### Unified SDK

```javascript
import { initAll } from "@amplitude/unified";

initAll("AMPLITUDE_API_KEY", {
  sessionReplay: {
    interactionConfig: {
      enabled: true,
      ugcFilterRules: [
        {
          selector: "https://example.com/user/*/profile",
          replacement: "https://example.com/user/USER_ID/profile",
        },
      ],
    },
  },
});
```

#### Standalone SDK

```javascript
import { sessionReplay } from "@amplitude/session-replay-browser";

sessionReplay.init("AMPLITUDE_API_KEY", {
  // ...
  // Other Configs
  // ...
  interactionConfig: {
    enabled: true,
    ugcFilterRules: [
      {
        selector: "https://example.com/user/*/profile",
        replacement: "https://example.com/user/USER_ID/profile",
      },
      {
        selector: "https://example.com/api/token=*",
        replacement: "https://example.com/api/token=REDACTED",
      },
    ],
  },
});
```

## Test patterns in a development environment first

Validate that your glob patterns match expected URLs in a development environment. The following array lists example URLs to include in your checks; it doesn't execute a test:

```javascript
// Test with various URL formats
const testUrls = [
  "https://mycompany.projecttool.com/browse/PROJ-123",
  "https://codehost.com/username/repository/tree/main/src/components",
  "https://myapp.com/user/john.doe@email.com/profile",
];
```

