---
title: "BrowserTracing"
description: "Capture browser traces for page loads and requests, and see where they fail or slow down."
url: https://docs.sentry.io/platforms/javascript/guides/capacitor/configuration/integrations/browsertracing/
---

# BrowserTracing for Capacitor

This integration only works inside a browser environment.

*Import name: `Sentry.browserTracingIntegration`*

With [tracing](https://docs.sentry.io/concepts/key-terms/tracing.md), Sentry follows page loads, navigations, and requests in the browser so you can see where they fail or slow down. Spans record each of those operations.

The BrowserTracing integration sets up automatic tracing for your frontend applications. It captures transactions and spans from the browser and sends them to Sentry.

Read more about [setting up BrowserTracing](https://docs.sentry.io/platforms/javascript/guides/capacitor/tracing.md).

```JavaScript
Sentry.init({
  integrations: [Sentry.browserTracingIntegration()],
});
```

See [Configuration Options](https://docs.sentry.io/platforms/javascript/guides/capacitor/tracing/instrumentation/automatic-instrumentation.md#configuration-options) for a full list of available options for `browserTracingIntegration`

## [Configuration Options](https://docs.sentry.io/platforms/javascript/guides/capacitor/configuration/integrations/browsertracing.md#configuration-options)

These options configure pageload and navigation spans.

### [instrumentPageLoad](https://docs.sentry.io/platforms/javascript/guides/capacitor/configuration/integrations/browsertracing.md#instrumentPageLoad)

| Type    | `boolean` |
| ------- | --------- |
| Default | `true`    |

Enable/disable automatic `pageload` span creation on initial page load.

### [instrumentNavigation](https://docs.sentry.io/platforms/javascript/guides/capacitor/configuration/integrations/browsertracing.md#instrumentNavigation)

| Type    | `boolean` |
| ------- | --------- |
| Default | `true`    |

Enable/disable automatic `navigation` span creation on history changes.

### [detectRedirects](https://docs.sentry.io/platforms/javascript/guides/capacitor/configuration/integrations/browsertracing.md#detectRedirects)

| Type    | `boolean` |
| ------- | --------- |
| Default | `true`    |

Detect redirects and avoid creating separate `navigation` spans for them. Set to `false` to create a span for every navigation.

### [beforeStartSpan](https://docs.sentry.io/platforms/javascript/guides/capacitor/configuration/integrations/browsertracing.md#beforeStartSpan)

| Type | `(options: StartSpanOptions) => StartSpanOptions` |
| ---- | ------------------------------------------------- |

Modify span data before it's captured. Useful for adding context or normalizing URLs with dynamic segments:

One common use case is parameterizing transaction names. For both `pageload` and `navigation` transactions, the `browserTracingIntegration` uses the browser's `window.location` value to generate a transaction name. Using `beforeStartSpan` lets you modify the transaction name to make it more generic, so that for example, transactions named `GET /users/12312012` and `GET /users/11212012` can both be renamed to `GET /users/:userid`. That way they'll be grouped together.

```javascript
Sentry.init({
  // ...
  integrations: [
    Sentry.browserTracingIntegration({
      beforeStartSpan: (context) => {
        return {
          ...context,
          // You could use your UI's routing library to find the matching
          // route template here. We don't have one right now, so do some basic
          // parameter replacements.
          name: location.pathname
            .replace(/\/[a-f0-9]{32}/g, "/<hash>")
            .replace(/\/\d+/g, "/<digits>"),
        };
      },
    }),
  ],
});
```

### [idleTimeout](https://docs.sentry.io/platforms/javascript/guides/capacitor/configuration/integrations/browsertracing.md#idleTimeout)

| Type    | `number` |
| ------- | -------- |
| Default | `1000`   |

Time in ms to wait before finishing a pageload/navigation span when no unfinished child spans remain.

### [finalTimeout](https://docs.sentry.io/platforms/javascript/guides/capacitor/configuration/integrations/browsertracing.md#finalTimeout)

| Type    | `number` |
| ------- | -------- |
| Default | `30000`  |

Maximum duration in ms for pageload/navigation spans. Spans exceeding this are automatically finished.

### [childSpanTimeout](https://docs.sentry.io/platforms/javascript/guides/capacitor/configuration/integrations/browsertracing.md#childSpanTimeout)

| Type    | `number` |
| ------- | -------- |
| Default | `15000`  |

Maximum time in ms a child span can run before the parent pageload/navigation span is finished.

### [markBackgroundSpan](https://docs.sentry.io/platforms/javascript/guides/capacitor/configuration/integrations/browsertracing.md#markBackgroundSpan)

| Type    | `boolean` |
| ------- | --------- |
| Default | `true`    |

Mark pageload/navigation spans as "cancelled" when the tab moves to background. Recommended to keep enabled for accurate measurements.

### [enableReportPageLoaded](https://docs.sentry.io/platforms/javascript/guides/capacitor/configuration/integrations/browsertracing.md#enableReportPageLoaded)

| Available since | `10.13.0` |
| --------------- | --------- |
| Type            | `boolean` |
| Default         | `false`   |

Enable the [`Sentry.reportPageLoaded()` function](https://docs.sentry.io/platforms/javascript/guides/capacitor/apis.md#reportPageLoaded).

---

Find other pages: [Sitemap](https://docs.sentry.io/sitemap.md) lists every page with a one-line summary, and [llms.txt](https://docs.sentry.io/llms.txt) gives an overview with guidance for agents.
