---
title: Direct Offer Conversion Tracking (OmniSDK + Google Tag Manager)
slug: direct-offer-conversion-tracking-omnisdk-google-tag-manager
icon: 📡
docTags: 
createdAt: 2025-02-23T21:20:36.898Z
---

:::hint{type="info"}
**Who is this for:** Advertisers and marketers who manage tracking through Google Tag Manager and want to implement conversion tracking without modifying website code.

**Outcome:** Set up MomentScience conversion tracking entirely through GTM using data layer variables, custom tags, and triggers for click ID capture and event firing.
:::

# Overview

This guide walks you through setting up conversion tracking with MomentScience using Google Tag Manager (GTM).

## Prerequisites

Before you begin, ensure you have:

- Your **MomentScience account ID**
- Your **landing page URLs**
- Your **conversion page URLs**

# Integration Steps

## Step 1: Configure accountId Data Variable in GTM&#x20;

To ensure MomentScience tracking works across all pages, you need to create a Data Layer Variable for your account ID.

::::VerticalSplit{layout="right"}
:::VerticalSplitItem
1. In **Google Tag Manager**, navigate to **Variables**.
2. Create a **new variable** of type **Data Layer Variable**.
3. Name it **accountId**.
4. Check **"Set Default Value"** and enter your **MomentScience account ID** as the default.

📌 *This ensures your account ID is accessible throughout your GTM setup.*
:::

:::VerticalSplitItem
![](https://api.archbee.com/api/optimize/ELjiwjWcrv0a1IejQFFAF/tL-JY_kGrhzT6w14nvObA_image.png "Configure accountId Data Variable in GTM ")
:::
::::

## Step 2: Add the MomentScience OmniSDK Tag

The **MomentScience OmniSDK** is required for tracking user interactions and conversions.&#x20;

:::::VerticalSplit{layout="right"}
::::VerticalSplitItem
1. In **GTM**, go to **Tags** and create a new tag of type **Custom HTML**.
2. In the **HTML field**, enter the following:

:::CodeblockTabs{indent="2"}
OmniSDK tag

```javascript
//📌 {{accountId}} references the Data Layer Variable from Step 1.
<script src="https://plugins.pubtailer.com/omnisdk.js?accountId={{accountId}}"></script>
```
:::

3. Set the trigger to **fire on all pages**.
4. Save and publish your changes.

✅ *This ensures that the OmniSDK is loaded on every page of your site for tracking purposes.*
::::

:::VerticalSplitItem
![](https://api.archbee.com/api/optimize/ELjiwjWcrv0a1IejQFFAF/gYHGOqNEKluiKXyW60bpw_image.png "Add the MomentScience OmniSDK Tag ")
:::
:::::

## Step 3: Implement Click Tracking on Landing Pages&#x20;

1. In **GTM**, create another tag of type **Custom HTML**.
2. Enter the following code:

:::CodeblockTabs{indent="2"}
```javascript
<script>
// This code simply looks for a click identifier in the 
// URL and saves to local cookie for later retrieval
// on conversion.
    handleAdpxClickId();
</script>
```
:::

3. Set the tag firing option to **Once per page**.
4. Under **Tag Sequencing**, select **"Fire tag before..."** and choose the OmniSDK tag from Step 2.
5. Under **Triggers**, configure the tag to fire **only on landing pages**.

📌 *This tag ensures that click IDs are properly captured for attribution.*

## Step 4: Implement Conversion Tracking on Key Event Pages

This step will guide you through setting up a **Custom HTML Tag** in GTM that fires only on pages where you want to track **conversion events** (e.g., purchases, signups, or registrations).

### A. Create Data Layer Variables for Events

::::VerticalSplit{layout="right"}
:::VerticalSplitItem
Before configuring the tag, we need to define **two Data Layer Variables** to hold:

1. **The event name** (e.g., conversion, purchase, lead).
2. **The event value** (e.g., the transaction amount).

**
:::

:::VerticalSplitItem
![](https://api.archbee.com/api/optimize/ELjiwjWcrv0a1IejQFFAF/q-u1Iwqzf2HaeSVE6n0Ce_image.png "User-defined variables of type Data Layer")
:::
::::

**Steps to Create Data Layer Variables**

1. In **Google Tag Manager (GTM)**, go to **Variables** → **New**.
2. Create a **Data Layer Variable** with the following settings:
   - **Variable Name:** eventName
   - **Set Default Value:** "conversion"
3. Create another **Data Layer Variable**:
   - **Variable Name:** amount
   - **Set Default Value:** 0

When you’re done, you should have 3 user-defined variables of type Data Layer.

📌 *Ensure these variables exist before proceeding to the next step.*

### B. Set Up the Conversion Tracking Tag

1. In **GTM**, go to **Tags** and create a new tag of type **Custom HTML**.
2. Enter the following JavaScript code:

:::CodeblockTabs{indent="2"}
```javascript
<script>
(function() {
    var sale_amount = {{amount}}; // Replace with actual sale amount (if available)
    // Main Tracking
    //get mosci_click_id from cookie (captured on landing page
    // and saved local to site)

    var mosciClickId = getCookie('mosci_click_id');
    var eventName = '{{eventName}}'; ///replace with actual event name

    trackMoSciEvent(mosciClickId, eventName, sale_amount)
        .then(function() {
            console.log('Tracking successful');
        })
        .catch(function(error) {
            console.error('Tracking failed:', error);
        });
})();
</script>
```
:::

3. Set the tag firing option to **Once per page**.
4. Under **Tag Sequencing**, select **"Fire tag before..."** and choose the OmniSDK tag you set up in **Step 2**.&#x20;
5. Under **Triggers**, configure the tag to fire **only on** **conversion pages**.

📌 *This script tracks conversions by capturing stored click IDs and sending them back to MomentScience.*

## Step 5: Configure Data Layer Variables on Your Website

To ensure Google Tag Manager (GTM) can correctly track conversions, you must pass Data Layer Variables on your site’s pages. This section explains how to include these variables in your website’s `<head>` section.

### A. Configure Data Layer Variables on Landing Pages&#x20;

On all landing pages, insert the following code above your GTM implementation in the`<head>` tag:

```javascript
<script>
    window.dataLayer = window.dataLayer || [];
    dataLayer.push({
    //📌 Replace YOUR_ACCOUNT_ID with your actual MomentScience account ID.
        'accountId': 'YOUR_ACCOUNT_ID'
    });
</script>
```

This ensures that your account ID is available in the Data Layer, allowing GTM to access it across different tracking tags.

### B. Configure Data Layer Variables on Conversion Pages

On all **conversion pages** (e.g., checkout success, registration complete), insert the following code **above your GTM implementation** in the`<head>` tag:

```javascript
<script>
    window.dataLayer = window.dataLayer || [];
    dataLayer.push({
//📌 Replace accountId with your actual MomentScience account ID.
        'accountId': 'YOUR_ACCOUNT_ID',
//📌 Replace EVENT_NAME with the actual event type (lead, cart, purchase, registration, etc.).
        'eventName': 'EVENT_NAME',
// 📌 Replace amount with the conversion value (if applicable).        
        'amount': 100
    });
</script>

```

### C. Handling Multiple Conversion Events

If your site includes multiple **conversion events** (e.g., add-to-cart → purchase), repeat the **Data Layer push** on each relevant page. For example:

1. **Cart Page (/cart)** → Track when users add items to their cart:

:::CodeblockTabs{indent="2"}
```javascript
<script>
    window.dataLayer = window.dataLayer || [];
    dataLayer.push({
        'accountId': 'YOUR_ACCOUNT_ID',
        'eventName': 'cart',
        'amount': 0
    });
</script>

```
:::

2. **Purchase Confirmation Page (/thank-you)** → Track completed purchases:

:::CodeblockTabs{indent="2"}
```javascript
<script>
    window.dataLayer = window.dataLayer || [];
    dataLayer.push({
        'accountId': 'YOUR_ACCOUNT_ID',
        'eventName': 'purchase',
        'amount': 250
    });
</script>
```
:::

:::hint{type="success"}
A live working example can be found [here](https://e.pubtailer.com/pub/index_tracking_gtm.html?adpx_click_id=testclickid).
:::

# Final Checklist

- [ ] **Step 1:** accountId is configured as a **Data Layer Variable**.
- [ ] **Step 2:** OmniSDK tag is **firing on all pages**.
- [ ] **Step 3:** Click tracking tag is **firing only on landing pages**.
- [ ] **Step 4:** Conversion tracking tag is **firing only on conversion pages**.
- [ ] **Step 5:** Data Layer Variables are **implemented correctly on your website**.

# Conclusion

By following these steps, you have successfully integrated MomentScience conversion tracking using Google Tag Manager. This setup ensures accurate tracking of user conversions while keeping your implementation scalable and flexible.

***

📢 If you're running into any issues while going through the integration process, feel free to contact us at [help@momentscience.com](mailto\:help@Momentscience.com)
