> ## Documentation Index
> Fetch the complete documentation index at: https://www.pagent.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Tag manager forwarding

> Forward test assignments and conversions to Google Tag Manager, JENTIS or any dataLayer

pagent can push test assignments and conversions into your own tag manager. From there you can send them to GA4, your ad platforms or your data warehouse with the tags you already have. No code is needed on your site.

## Set it up

1. In pagent, open **Integrations** and click **Configure** on the **Tag Managers** card.
2. Under **Destinations**, turn on one or more:
   * **Google Tag Manager** pushes to `window.dataLayer`. If your container uses a different array, change **dataLayer name**.
   * **JENTIS** pushes to the JENTIS tag (`_jts`) once it has loaded. Events fired before that are queued for up to 30 seconds.
   * **Custom dataLayer** pushes into any named window array, for Tealium, Adobe Launch, Piwik PRO or your own. Enter the **Array name**.
3. Optionally change the **Field prefix** (default `pagent_`). It is prepended to every event name and field.
4. Under **Forwarded events**, choose what to send. See below.
5. Save. Your site picks up the change within a minute.

To check it, open GTM Preview on your site and look for the `pagent_assignment` event on page load.

## Forwarded events

| Toggle | Default | Event name | When |
| - | - | - | - |
| **Test assignment** | On | `pagent_assignment` | On every page view where the visitor is in a test, once per test. |
| **Conversions** | On | `pagent_conversion` | When a conversion is recorded in the browser. |
| **Opt-in** | Off | `pagent_opt_in` | When the visitor opts in to pagent tracking. |
| **Opt-out** | Off | `pagent_opt_out` | When the visitor opts out of pagent tracking. |

Raw analytics (clicks, scrolls, hovers) is never forwarded. Visitors who opted out of pagent are never forwarded. Anything else, including what your tags do with the data, follows your tag manager's own consent setup.

### Test assignment

Assignment is pushed again on every page view, because tag managers start a fresh data model on each page load. That way your own tags always have the test context available as dataLayer variables.

```javascript theme={"dark"}
{
    event: "pagent_assignment",
    pagent_experiment_id: "3f2a…",
    pagent_experiment_name: "Pricing page headline",
    pagent_variation_id: "9b1c…",
    pagent_variation_name: "Variant A",
    pagent_is_control: false,
    pagent_test: "Pricing page headline:Variant A",
    // every test the visitor is in, for joins and reports
    pagent_experiments: { "3f2a…": "9b1c…" },
    pagent_tests: "Pricing page headline:Variant A"
}
```

A visitor in two tests gets two assignment pushes. `pagent_experiments` and `pagent_tests` list all of them in both pushes; `pagent_tests` joins them with `|`.

### Conversions

All conversions share the `pagent_conversion` event name, with the goal in a field. That way renaming a goal never breaks a GTM trigger.

```javascript theme={"dark"}
{
    event: "pagent_conversion",
    pagent_goal: "purchase",
    pagent_goal_id: "c71e…",          // omitted when the label matches no goal
    pagent_conversion_origin: "dom",  // "dom" (click goal), "page_view" or "programmatic"
    pagent_revenue: 2499,             // cents, when present
    pagent_properties: { … },         // when present
    pagent_experiments: { "3f2a…": "9b1c…" },
    pagent_tests: "Pricing page headline:Variant A"
}
```

<Note>
  Forwarded conversions are the ones the SDK records in the browser: **click goals**, **page view goals** and deprecated programmatic conversions. **Event goals are not forwarded**, because pagent computes them from your events after the fact. Events observed from your dataLayer are already in your tag manager. For events you send with `window._pgnt.push`, push the same event to your dataLayer as well, or forward it from the [`pagent:event` listener](/docs/guides/tracking/event-listener).
</Note>

## Using it in GTM

A typical GA4 setup:

1. Create **Data Layer Variables** for `pagent_experiment_id`, `pagent_variation_id` and `pagent_test`.
2. Create a **Custom Event** trigger on `pagent_assignment`.
3. Add a **GA4 Event** tag, for example `experience_impression`, that sends `pagent_test` as a parameter and fires on that trigger.

Everything pagent pushes carries `_pagent_forwarded: true`. pagent ignores those entries when it [observes your dataLayer](/docs/guides/tracking/instrumentation), so forwarded conversions are never counted a second time as events.

## Before forwarding existed

Earlier integrations forwarded data with a hand-written `pagent:event` listener, as in the [JENTIS example](/docs/guides/tracking/event-listener#example-integration). That still works. If you switch to forwarding, remove the listener so events are not sent twice.
