> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/umbraco-engage/developers/analytics/extending-analytics/sending-data-to-the-gtm-datalayer.md).

# Sending data to the GTM Datalayer

Discover how to push A/B testing and personalization variables from Umbraco Engage to the Google Tag Manager (GTM) data layer in Razor templates.

Umbraco Engage provides a partial view that pushes variables related to A/B testing and personalization to the Google Tag Manager (GTM) data layer.

The following variables are pushed:

* `inabtest: true` - if the visitor participates in an active A/B test on the page; otherwise `false`.

{% hint style="info" %}
This will also be **true** if the visitor is assigned to the "A" variant which is the original page.
{% endhint %}

* `abtestname` - The name of the A/B test the visitor is participating in. If there is no active A/B test, the value will be `null`
* `abtestvariant` - The name of the A/B test variant assigned to the visitor. If there is no active A/B test, the value will be `null`
* `personalized: true` - If personalization is applied to the page for the visitor; otherwise `false`.
* `personalizationname` - The name of the active personalization. If there is no active personalization, the value will be `null`.

To render the partial view in your Razor template, use the following line:

```cs
@Html.Partial("~/Views/Partials/Umbraco.Engage/GTMDataLayerPush.cshtml")
```

This partial will render the following output:

```html
<script>
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
        inabtest: true,
        abtestname: "The name of the AB test",
        personalized: true,
        personalizationname: "The name of the personalized variant",
    });
</script>
```


---

# 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.umbraco.com/umbraco-engage/developers/analytics/extending-analytics/sending-data-to-the-gtm-datalayer.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.
