> For the complete documentation index, see [llms.txt](https://docs.mediarithmics.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mediarithmics.io/setup-and-monitor/plan-and-integrate/set-up-advanced-features/edge.md).

# Edge

Enable browser-side segment computation for near real-time on-site targeting.

## Your goal

Enable Edge so that segments are computed in the user's browser as they navigate, and can be acted on during the same visit.

## Expected outcome

Your sites run the latest tag, the properties Edge needs are flagged in your schema, your ad server is wired up, and Edge segments enter and exit in near real time as users browse.

## What Edge is

**Edge** is a segmentation feature that runs **client-side, in the user's browser**, rather than relying on server-side segmentation. Each user's own browser evaluates whether they belong to a segment, based on their interactions with your site - which makes the segmentation close to real time.

The contrast with the default behaviour is the point of the feature:

{% columns %}
{% column %}

### Edge segments

Segmentation is executed by the end user's browser, so it is computed in near real time. A user enters a segment while browsing, as soon as the criteria match.
{% endcolumn %}

{% column %}

### Server-side segments

mediarithmics processes segmentation on its servers, typically overnight, comparing user attributes against the segment's query. The audience is updated and activated on a daily basis.
{% endcolumn %}
{% endcolumns %}

{% hint style="info" %}
Only users who browsed your site with Edge active are in an Edge segment.
{% endhint %}

## How it works

```mermaid
sequenceDiagram
    participant U as User's browser
    participant T as mediarithmics tag
    participant M as mediarithmics
    participant A as Google Ad Manager
    U->>T: Page view
    T->>T: Store visit timeline in local storage
    T->>M: Send event to the activity pipeline
    T->>M: Fetch Edge segment definitions
    T->>T: Evaluate definitions against the visit timeline
    T->>U: Store matching segments in local storage
    T->>A: Push segment IDs as key-values on the ad call
    T->>M: Sync segment membership for analytics
```

Step by step:

1. The user visits the site and the mediarithmics tag runs. The user's **visit timeline** is stored in local storage.
2. The browser **fetches the Edge segment definitions** from mediarithmics and downloads them all - they are JavaScript-based segment queries.
3. The browser **evaluates those definitions against the visit timeline**.
4. The segments the user belongs to are stored in local storage, and synchronised with mediarithmics for analytics. Segment statistics are computed periodically by counting users flagged as belonging to the segment; **updates can take up to 24 hours**.
5. Edge segments are activated on Google using **key-value targeting** through the Google Publisher Tag.

When an event is pushed by the tag it is sent both to the activity processing pipeline and saved locally, which is what lets the browser evaluate criteria without a round trip.

## Set it up

{% stepper %}
{% step %}

### Check the prerequisites

* **Snippet version.** Your site must run the latest version of the mediarithmics snippet. See [Web tracking](/setup-and-monitor/collect-and-manage-your-data/collect-data-in-real-time/web-tracking.md).
* **Feature activation.** Edge is not available by default. Contact your account manager to enable it on the channels concerned.
  {% endstep %}

{% step %}

### Flag the schema properties Edge can use

Identify the properties needed for Edge-based segmentation and mark them with the `@EdgeAvailability` directive in your schema. See [Schema definition](/setup-and-monitor/collect-and-manage-your-data/design-your-data-model-and-schema/schema-definition.md).

Requirements you must meet:

| Requirement           | Detail                                                                                                                                                 |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Supported objects** | Only properties of `UserDeviceTechnicalId`, `DeviceInfo`, `UserSegment`, and `UserEvent` - including all its sub-object properties.                    |
| **Data integrity**    | Properties must exist in the schema and be stored exactly as pushed by the tag. No transformation can be applied - no event rules, no visit analyzers. |
| **Directives**        | A property using `@PropertyPath` is only compatible if the path name and the property name are identical in both the schema and the data layer.        |

{% hint style="info" %}
Validate your schema changes with the mediarithmics technical team before deploying them.
{% endhint %}
{% endstep %}

{% step %}

### Connect your delivery platform

* **Google Ad Manager.** The JavaScript snippet pushes segment IDs as key-values on the ad call automatically, but the key-values themselves must be created manually in the Google Ad Manager interface.
* **Other platforms.** There is no native integration yet, but segment IDs are stored and available in local storage, so an integration can be implemented on your side.

During setup you can agree a custom targeting key - a `namespace` - with your account manager. It is automatically prefixed with `mics_`: a namespace of `dogfooding` produces the Google Ad Manager targeting key `mics_dogfooding`.
{% endstep %}

{% step %}

### Add server-side activation if you need it

An Edge segment can also carry a regular server-side feed, so the same audience can be activated on other platforms.
{% endstep %}
{% endstepper %}

## Consent and compliance

Edge follows the same consent-management requirements as the rest of the platform. See [Manage consent & Processing activities](/setup-and-monitor/ensure-privacy-and-compliance/manage-consent-and-processing-activities.md).

## What is stored in the browser

| Item               | Storage                                                                                                                                          | Persistence                                          |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------- |
| **Visit timeline** | Up to 200 events per domain and user. Beyond that, each new event replaces the oldest. Stored under the local-storage key `<namespace>_mics_up`. | No time limit - no automatic cleaning or expiration. |
| **Segments**       | No limit on how many are stored. Stored under the local-storage key `mics_sgmts`.                                                                | No time limit - no automatic cleaning or expiration. |

{% hint style="warning" %}
Because nothing expires client-side, a time-sensitive criterion behaves differently from its server-side equivalent. If a segment means "visited a product page in the last 10 days" and the user does not come back to the site, they will **not** automatically leave the segment when they stop matching.
{% endhint %}

## Choosing between Edge and server-side

Edge is particularly useful for instant on-site personalisation and targeting, and it trades that speed against limitations on data retention, cross-site behaviour, and attribute availability.

For high-volume, precision-driven segmentation that needs cross-site tracking and broader data aggregation, **server-side segmentation remains the recommended approach**.

## Verify

* The latest snippet is deployed on the channels where Edge is enabled.
* Every property your Edge segment queries uses is flagged `@EdgeAvailability` and is stored untransformed.
* Segment IDs appear in local storage under `mics_sgmts` while browsing.
* The corresponding key-values exist in Google Ad Manager, and appear on the ad call.
* Segment statistics appear in the platform - allowing up to 24 hours.

## Related pages

<table data-view="cards" data-search="false"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Web tracking</strong></td><td>Deploy and update the snippet Edge depends on.</td><td><a href="/setup-and-monitor/collect-and-manage-your-data/collect-data-in-real-time/web-tracking.md">Web tracking</a></td></tr><tr><td><strong>Schema definition</strong></td><td>Where the <code>@EdgeAvailability</code> directive is declared.</td><td><a href="/setup-and-monitor/collect-and-manage-your-data/design-your-data-model-and-schema/schema-definition.md">Schema definition</a></td></tr><tr><td><strong>Platform limits</strong></td><td>The client-side storage ceilings.</td><td><a href="/setup-and-monitor/plan-and-integrate/set-up-the-environment/platform-limits.md">Platform limits</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mediarithmics.io/setup-and-monitor/plan-and-integrate/set-up-advanced-features/edge.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
