---
title: "Scopes"
description: "Learn what the scope is in the Sentry Unity SDK, and how to attach data to all events or to a single event."
url: https://docs.sentry.io/platforms/unity/enriching-events/scopes/
last_updated: 2026-11-16T12:24:03.000Z
---

# Scopes for Unity

When an event is captured and sent to Sentry, the SDK merges that event with the data stored on the scope, such as [tags](https://docs.sentry.io/platforms/unity/enriching-events/tags.md), [contexts](https://docs.sentry.io/platforms/unity/enriching-events/context.md), [breadcrumbs](https://docs.sentry.io/platforms/unity/enriching-events/breadcrumbs.md), and the [user](https://docs.sentry.io/platforms/unity/enriching-events/identify-user.md).

## [How the Scope Works](https://docs.sentry.io/platforms/unity/enriching-events/scopes.md#how-the-scope-works)

Unity runs in global mode, with one scope shared by every thread. Data you set on the scope stays there and is added to every event until you change or clear it. `PushScope` has no effect.

Native crashes include most of this data too. Learn more in [Scope Sync](https://docs.sentry.io/platforms/unity/native-support.md#scope-sync).

## [Configuring the Scope](https://docs.sentry.io/platforms/unity/enriching-events/scopes.md#configuring-the-scope)

The most useful operation when working with scopes is the `ConfigureScope` function. It can be used to reconfigure the current scope.

You can, for instance, add custom tags or inform Sentry about the currently authenticated user.

```csharp
using Sentry;
using Sentry.Unity;

SentrySdk.ConfigureScope(scope =>
{
    scope.SetTag("my-tag", "my value");
    scope.User = new SentryUser
    {
        Id = "42",
        Email = "john.doe@example.com"
    };
});
```

You can also apply this configuration when unsetting a user at logout:

```csharp
SentrySdk.ConfigureScope(scope =>
{
    scope.User = new SentryUser();
});
```

*Other available variations of the above snippet: fsharp*

## [Attaching Data to a Single Event](https://docs.sentry.io/platforms/unity/enriching-events/scopes.md#attaching-data-to-a-single-event)

### [Using Scope Callback Parameter](https://docs.sentry.io/platforms/unity/enriching-events/scopes.md#using-scope-callback-parameter)

In the following example we use the scope callback parameter that is available for all `capture` methods to attach a `level` and a `tag` to only one specific error:

```csharp
// will be tagged with my-tag="my value"
SentrySdk.CaptureException(new Exception("my error"), scope =>
{
    scope.SetTag("my-tag", "my value");
    scope.Level = SentryLevel.Warning;
});

// will not be tagged with my-tag
SentrySdk.CaptureException(new Exception("my other error"));
```

*Other available variations of the above snippet: fsharp*

Before the callback is invoked the SDK creates a clone of the current scope, and the changes made will stay isolated within the callback function. This allows you to more easily isolate pieces of context information to specific locations in your code or even call `clear` to briefly remove all context information.

##### Important

Any exceptions that occur within the callback function for configuring a local scope will not be caught, and all errors that occur will be silently ignored and **not** reported.

---

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.
