# How to setup tracking with GTM?

\
![:small\_blue\_diamond:](https://a.slack-edge.com/production-standard-emoji-assets/14.0/apple-medium/1f539@2x.png) Step 1: Capture `reid` from **URL param** into Cookie\
**Create new Tag:**

* Type: Custom HTML
* Name: `ReEngage - Save reid to Cookie`
* HTML:

```html
<script>
  (function() {
    var reid = new URLSearchParams(window.location.search).get('reid');
    if (reid) {
      document.cookie = "reid=" + reid + "; path=/; max-age=" + 60 * 60 * 24 * 30;
    }
  })();
</script>
```

Trigger: All Pages

<figure><img src="/files/QXEa1SiPJEmiqEhy5j2E" alt=""><figcaption></figcaption></figure>

\
![:small\_blue\_diamond:](https://a.slack-edge.com/production-standard-emoji-assets/14.0/apple-medium/1f539@2x.png) Step 2: Read `reid` from Cookie\
**Create new Variable:**<br>

* Name: `ReEngage - Click ID from Cookie`
* Type: Custom JavaScript

```javascript
function() {
  var match = document.cookie.match(/(?:^|; )reid=([^;]*)/);
  return match ? match[1] : '';
}
```

<figure><img src="/files/fBwfsLTUH52YHBsfnMGH" alt=""><figcaption></figcaption></figure>

![:small\_blue\_diamond:](https://a.slack-edge.com/production-standard-emoji-assets/14.0/apple-medium/1f539@2x.png) Step 3: Send Postback on Conversion\
Tag:<br>

* Type: Custom Image
* Name: `ReEngage - Conversion Postback`
* URL:

```html
https://api.reengage.ai/postback/team1/YQUVxOc7pxglaJ1k361oqWuusd0UPQin63W4AEorkSw/?reid={{ReEngage - Click ID from Cookie}}&revenue={{replace_with_your_purchase_amount_variable}}
```

**Important notes:**&#x20;

1. **Take your unique tracking link in your tracking setup dashboard** [**https://reengage.ai/dashboard/setup**](https://reengage.ai/dashboard/setup)

2. In the URL, replace this part `{`replace\_click\_id`}` with **{{ReEngage - Click ID from Cookie}}**

3. In this URL, replace this part {replace\_conversion\_value} with your existing GTM variable that contains the **purchase amount** (e.g., total transaction value).

For example, if your GTM variable is named `Transaction Value`, update the postback like this:

```
...&revenue={{Transaction Value}}
```

#### 🧠 Example Final URL in GTM Tag:

```
https://api.reengage.ai/postback/team1/YQUVxOc7pxglaJ1k361oqWuusd0UPQin63W4AEorkSw/?reid={{ReEngage - Click ID from Cookie}}&revenue={{Transaction Value}}
```

> **Note:** You must have both the `ReEngage - Click ID from Cookie` and the correct `purchase value` GTM variables already configured.

Trigger: Use the existing **conversion** trigger that you use in your GTM<br>

* `reid` is saved on the first page view (from URL)
* `revenue` is pulled from `you_variable_for_purchase_amount`
* Postback fires on successful purchase

<figure><img src="/files/ZuVkHJChGWpPsVFkIHbv" alt=""><figcaption></figcaption></figure>

To test it out, you can use GTM debug tool or browser dev tools with custom param reid=reid\_afzgntgixuc, it should be sent in GET request like so:

<figure><img src="/files/ivodEQomJ87onXXulSZX" alt=""><figcaption></figcaption></figure>

4 files&#x20;


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.reengage.ai/advance-topics/how-to-setup-tracking-with-gtm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
