# Integrate Consent Mode on impact.com

Consent mode on impact.com is designed to adapt tracking behaviors based on the user's consent status, ensuring compliance with the ePrivacy Directive and similar regulations requiring user consent for cookies for tracking and analytics.

{% hint style="success" %}
**Note:** For further information on Consent Mode and how it works, view [Ensure GDPR Compliance using Consent Mode](https://help.impact.com/en/support/solutions/articles/155000003822).
{% endhint %}

## Implementation Overview

### Prerequisites

* Access to your website’s Consent Management Platform (CMP)
* Basic familiarity with JavaScript
* impact.com account access

## Detailed Implementation Steps

{% stepper %}
{% step %}

### Integrate the JavaScript Tag

1. Obtain the UTT JavaScript code:
   * From the top navigation bar in impact.com, select ![](/files/UDyrrRTGbHJFFllCZxyw) **\[User profile]** → **Settings** → **Tracking** → [**General**](https://app.impact.com/secure/advertiser/fr/general-tracking-settings.ihtml).
2. Add the JavaScript tag to your site:
   * Ensure the tag is placed correctly on every website page to function effectively.
3. Initialize the consent command with a *default* status, which your CMP should set based on the user's consent and the legal requirements of their location.

#### Example

{% tabs %}
{% tab title="JavaScript" %}

```javascript
<script>
  // If user consent is not required:
  ire("consent", "default", { "tracking": "granted" });
</script>
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### Update Consent Status Based on User Interaction

Dynamically update the consent state in response to user interactions with the consent banner:

#### Example

{% tabs %}
{% tab title="JavaScript" %}

```javascript
<script>
  // User grants consent
  ire("consent", "update", { "tracking": "granted" });

  // User denies consent
  ire("consent", "update", { "tracking": "denied" });
</script>
```

{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### Implement Conversion Tracking

#### Server-Side

If using our Conversions API to send conversions, follow the below guidance to implement in consent mode:

1. Include any relevant first-party identifiers. For example, if you specified `CustomProfileId` in the tag’s `identify` function call, we recommend sending the `CustomProfileId` with the conversion event.
2. Use `generateClickId` to obtain an encoded first-party user identifier on your pages. Send this parameter along with the conversion event.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
<script>
  ire("generateClickId", function(click_id) {
    console.log(click_id);
  });
</script>
```

{% endtab %}
{% endtabs %}

3. Send all conversion events for users referred by loyalty or rewards partners along with the relevant identifiers, even if the user didn’t provide consent. To identify such conversions, you can check for the presence of `impact-loyalty` localStorage object or manually store an identifier if the user’s initial navigation contains the`im_rewards=1` flag in the landing page URL query string.
4. To accurately assess the impact of partner referrals in scenarios where user consent is not provided, it is crucial to send all conversion events. However, for conversions from non-consented users, ensure that personally identifiable information (PII) such as customer IDs, emails, and click IDs is excluded from the event data. This approach allows us to maintain privacy compliance while still gaining valuable insights into the effectiveness of partner referrals without user consent.

#### JavaScript

Our JavaScript tag’s conversion tracking is natively implemented with consent mode and respects the user's preference for setting cookies and sending identifiers.
{% endstep %}

{% step %}

### Activate Consent Mode

Collaborate with your impact.com implementation engineer to activate consent mode for your program.

#### Implementation Example

{% hint style="warning" %}
**Important:** Always invoke the consent command before the identify command to ensure the default settings are applied correctly. Incorrect order can lead to non-functional consent defaults.

Also make sure to use your own UTT snippet from your Technical Implementation Plan, or alternatively, replace the placeholder in the snippet templates below with your unique filename.
{% endhint %}

### Identify Event

To make an identify when the user hasn’t provided consent:

{% tabs %}
{% tab title="JavaScript" %}

```javascript
(function(a, b, c, d, e, f, g) {
  e['ire_o'] = c;
  e[c] = e[c] || function() {
    (e[c].a = e[c].a || []).push(arguments)
  };
  f = d.createElement(b);
  g = d.getElementsByTagName(b)[0];
  f.async = 1;
  f.src = a;
  g.parentNode.insertBefore(f, g);
})(
  'https://utt.impactcdn.com/[INSERT THE FILENAME FROM YOUR TECHNICAL IMPLEMENTATION PLAN HERE].js',
  'script',
  'ire',
  document,
  window
);
ire('consent', 'default', {'tracking': 'denied'});
ire('trackConversion', actionTrackerId, {properties}, {options});
```

{% endtab %}
{% endtabs %}

On the same page, to update the consent status when the user provides consent:

{% tabs %}
{% tab title="JavaScript" %}

```javascript
ire('consent', 'update', {'tracking':'granted'});
```

{% endtab %}
{% endtabs %}

### Track Conversion Event

Send a conversion when the user hasn’t provided consent:

{% tabs %}
{% tab title="JavaScript" %}

```javascript
(function(a, b, c, d, e, f, g) {
  e['ire_o'] = c;
  e[c] = e[c] || function() {
    (e[c].a = e[c].a || []).push(arguments)
  };
  f = d.createElement(b);
  g = d.getElementsByTagName(b)[0];
  f.async = 1;
  f.src = a;
  g.parentNode.insertBefore(f, g);
})(
  'https://utt.impactcdn.com/[INSERT THE FILENAME FROM YOUR TECHNICAL IMPLEMENTATION PLAN HERE].js',
  'script',
  'ire',
  document,
  window
);
ire('consent', 'default', {'tracking': 'denied'});
ire('identify', {customerId: 'Customer Id', customerEmail: 'SHA1 Email Address'});
```

{% endtab %}
{% endtabs %}

Send a conversion when consent is granted:

{% tabs %}
{% tab title="JavaScript" %}

```javascript
(function(a, b, c, d, e, f, g) {
  e['ire_o'] = c;
  e[c] = e[c] || function() {
    (e[c].a = e[c].a || []).push(arguments)
  };
  f = d.createElement(b);
  g = d.getElementsByTagName(b)[0];
  f.async = 1;
  f.src = a;
  g.parentNode.insertBefore(f, g);
})(
  'https://utt.impactcdn.com/[INSERT THE FILENAME FROM YOUR TECHNICAL IMPLEMENTATION PLAN HERE].js',
  'script',
  'ire',
  document,
  window
);
ire('consent', 'default', {'tracking': 'granted'});
ire('trackConversion', actionTrackerId, {properties}, {options});
```

{% endtab %}
{% endtabs %}
{% endstep %}
{% endstepper %}

## Detailed Tag Overview

The JavaScript tag implements the following behaviors when the consent function call is made on the page.

#### When consent is required:

* The UTT will queue events using the browser’s localStorage but not store tracking cookies or send tracking or user identity data to the server.
* The UTT will send a profiling event to the server that consent was requested from the user.
* If the `im_rewards` flag is set, we will place cookies and send the current event to the server, but no queued events.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
ire('consent', 'default', {'tracking':'denied'});
```

{% endtab %}
{% endtabs %}

#### User grants consent:

* Place tracking cookies.
* Send all queued events and user identity data to the server.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
ire('consent', 'update', {'tracking':'granted'});
```

{% endtab %}
{% endtabs %}

#### User denies consent:

* Send a profiling request with consentStatus: denied.
* Delete all queued data except for data related to loyalty/rewards events.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
ire('consent', 'update', {'tracking':'denied'});
```

{% endtab %}
{% endtabs %}


---

# 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://integrations.impact.com/integration-guides/for-brands/tracking-integrations/integrate-consent-mode-on-impact.com.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.
