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

# Google Tag Manager (GTM) Integration

> How to configure your data layer, create data variables, and implement Mention Me tags using Google Tag Manager.

Setting up Mention Me through Google Tag Manager (GTM) is a flexible way to launch your referral programme with minimal development effort. This guide covers configuring your data layer, creating data variables, and implementing the core tags: Referrer, Referee, Landing Page, and Dashboard.

## Your Datalayer

Include first name, surname, email address, order total, order currency and, if running referral in multiple languages, locale.

Enter the name of each variable added for the JavaScript code. These must match your JavaScript. Repeat for first name, surname, email, locale, order total and order currency.

For more information about the data layer, see: [GTM Data Layer Dev Guide](https://developers.google.com/tag-manager/devguide)

## Data Variables

Create a variable for each parameter (`name`, `surname`, `email`, `order_number`, `order_subtotal`, `order_currency`, `locale`, `coupon_code`).

<Steps>
  <Step title="Open Variables">
    In GTM, go to *Variables* and click *NEW* under *User-Defined Variables*.
  </Step>

  <Step title="Create a Data Layer Variable">
    Click *Choose a variable type...* and choose *Data Layer Variable*. Add a variable name.
  </Step>

  <Step title="Save">
    Save the variable. Repeat for each parameter.
  </Step>
</Steps>

<img src="https://mintcdn.com/mentionme/V2LNKGCh7ROBia07/images/knowledge/tags/4411254657297.png?fit=max&auto=format&n=V2LNKGCh7ROBia07&q=85&s=de789529a393149e806db2be02f1ddc8" alt="GTM data layer variable configuration" width="2570" height="1294" data-path="images/knowledge/tags/4411254657297.png" />

## Tag Implementation

The basic integration consists of 3 tags: referrer, referee and landing page.

<Steps>
  <Step title="Create a new tag">
    In GTM, go to *Tags* and click *NEW*.
  </Step>

  <Step title="Configure as Custom HTML">
    Click *Choose a tag type...* and choose *Custom HTML*. Name the tag.
  </Step>

  <Step title="Add tag code and triggering">
    Add the tag code (see below) and select triggering, then save.
  </Step>
</Steps>

### Referrer tag

Replace each variable in curly brackets with your data layer variable name:

```html theme={null}
<script type="text/javascript" src="https://tag-demo.mention-me.com/api/v2/referreroffer/yourPartnerCodeGoesHere?situation=postpurchase&email={{email}}&surname={{surname}}&firstname={{firstname}}&locale={{locale}}&order_currency={{order_currency}}&order_subtotal={{total}}&order_number={{order_number}}&coupon_code={{coupon_code}}"></script>
```

**Trigger:**

* Scroll to *Triggering* and click *Choose a trigger...*
* Click `+` to add a new trigger
* Choose *Custom Event* (e.g., on purchase), or *Page View – DOM Ready* (e.g., when URL contains "confirmation")

<img src="https://mintcdn.com/mentionme/V2LNKGCh7ROBia07/images/knowledge/tags/4411258217745.png?fit=max&auto=format&n=V2LNKGCh7ROBia07&q=85&s=0dc13800c8f4fe9bc92003f0778df027" alt="GTM referrer tag trigger configuration" width="2048" height="924" data-path="images/knowledge/tags/4411258217745.png" />

### Referee tag

```html theme={null}
<script type="text/javascript" src="https://tag-demo.mention-me.com/api/v2/refereefind/yourPartnerCodeGoesHere?situation=checkout&locale={{locale}}"></script>
```

**Trigger:**

* Add a new trigger: usually *Custom Event* (e.g. "Proceed to checkout"), *Page View – DOM Ready* (e.g. when URL contains "checkout"), or *History Change* (for SPAs).

<img src="https://mintcdn.com/mentionme/V2LNKGCh7ROBia07/images/knowledge/tags/4411276199697.png?fit=max&auto=format&n=V2LNKGCh7ROBia07&q=85&s=d674646dfaa273951f4e5c2de9749725" alt="GTM referee tag trigger configuration" width="2028" height="876" data-path="images/knowledge/tags/4411276199697.png" />

Add this div next to your coupon code box:

```html theme={null}
<!-- Begin Mention Me referee placeholder div -->
<div id="mmWrapper"></div>
<!-- End Mention Me referee placeholder div -->
```

### Landing page tag

```html theme={null}
<script type="text/javascript" src="https://tag-demo.mention-me.com/api/v2/referreroffer/yourPartnerCodeGoesHere?situation=landingpage&locale={{locale}}"></script>
```

**Trigger:**

* Add a new *Page View – DOM Ready* trigger (e.g., when URL contains "refer-a-friend")

Create the landing page and add:

```html theme={null}
<!-- Begin Mention Me referrer placeholder div -->
<div id="mmWrapper"></div>
<!-- End Mention Me referrer placeholder div -->
```

### Dashboard (within account page) tag

Replace variables in curly brackets with your data layer variable names:

```html theme={null}
<!-- Begin Mention Me dashboard integration -->
<script type="text/javascript">
if (window.MentionMeFiredTags != undefined && window.MentionMeFiredTags != '') {
  var situation = 'dashboard';
  var implementation = 'embed';
  if (window.MentionMeFiredTags[implementation + situation] == true) {
    delete window.MentionMeFiredTags[implementation + situation];
  }
}
</script>
<script src="https://tag-demo.mention-me.com/api/v2/dashboard/yourPartnerCodeGoesHere?email={{email}}&surname={{surname}}&firstname={{firstname}}&locale={{locale}}&situation=dashboard&implementation=embed"/>
<!-- End Mention Me dashboard integration -->
```

**Trigger:**

* Add a new *Page View – DOM Ready* trigger (e.g., when URL contains "dashboard")

Create a dashboard page within your Customer Account area, then add:

```html theme={null}
<!-- Begin Mention Me dashboard placeholder div -->
<div id="mmWrapper"></div>
<!-- End Mention Me dashboard placeholder div -->
```

## Testing

Use preview mode to place an order on your live site and check you have set up the variables correctly. You can also give us access to the GTM Preview so we can test the tags.

<img src="https://mintcdn.com/mentionme/V2LNKGCh7ROBia07/images/knowledge/tags/4411269154961.png?fit=max&auto=format&n=V2LNKGCh7ROBia07&q=85&s=5a3b9e25f01ccac621ad9da2bba57078" alt="GTM preview mode for testing tags" width="1354" height="516" data-path="images/knowledge/tags/4411269154961.png" />

### Publish

Once the demo tags have been tested, remove the `-demo` from the tag URLs and publish live.

<Steps>
  <Step title="Submit for publishing">
    Click *Submit* and choose *public*.
  </Step>

  <Step title="Create a version">
    Add a name and description.
  </Step>

  <Step title="Publish">
    Publish the container.
  </Step>
</Steps>

<Frame caption="GTM publish and version creation">
  <img src="https://mintcdn.com/mentionme/V2LNKGCh7ROBia07/images/knowledge/tags/4411284545809.png?fit=max&auto=format&n=V2LNKGCh7ROBia07&q=85&s=f103cec79f78d3ed1ab21dfabc5a3cde" alt="GTM publish and version creation" width="1354" height="516" data-path="images/knowledge/tags/4411284545809.png" />
</Frame>

For more information about publishing tags on GTM, please visit: [GTM Tag Publishing](https://support.google.com/tagmanager/answer/6107163?hl=en)
