Installation and Setup¶
Before you begin, verify that your GTM configuration works on all pages of your site. If your site runs Shopify in headless mode, double check that GTM also fires on your checkout page. If not, integrate the Shopify Pixel to capture events on your checkout page.
A. Installing the iPixel¶
Step 1: Log in to your Google Tag Manager account. Click your website's container, and under Tags, click New. For Tag Configuration, choose Custom HTML. Enter a name, for example "iPixel-Init".
Step 2: Copy and paste the following code into your tag. Replace <<YOUR-EVENT-KEY>> with the advertiser key shared by the Glance team.
<script>
var ADVERTISER_KEY = "<<YOUR-EVENT-KEY>>";
!function(w,d){
var cacheBust = Date.now();
var s = [
"https://i.l-dsp.inmobicdn.net/helix-cors/custom/js/d2c/idspPixel/prod/gpixel.js?cb=" + cacheBust
];
if(!w.InmobiPixel){
var p=w.InmobiPixel=function(){
p.performOperation ? p.performOperation.apply(p,arguments) : p._queue.push(arguments);
};
p._queue=[]; p.ts=Date.now();
var f=d.getElementsByTagName("script")[0];
for(var i=0;i<s.length;i++){
var x=d.createElement("script");
x.async=true;
x.src=s[i];
x.fetchPriority = "high";
f.parentNode.insertBefore(x,f);
}
}
}(window,document);
InmobiPixel("init");
</script>
Step 3: Click under Triggering and select Initialization - All Pages. This ensures that the iPixel loads on all pages. Click Save.
Caution
Pixel should load and initialize on each page of your site. Ensure that your GTM Initialization - All Pages Trigger fires on each page to which you send an event.
Note
At a minimum, provide page_view, view_item, add_to_cart, begin_checkout, and purchase events. Also include sign_up or login if your site uses these events.
B. Tracking Events with iPixel¶
To send an occurrence of an ecommerce event to iPixel, use the following syntax. Each event should trigger when its corresponding event happens in the data layer.
<script>
InmobiPixel("track", <<event-name>>, <<event-data>>);
</script>
Parameters:
| Name | Type | Description |
|---|---|---|
event_name |
string | The name for this event. See iPixel Events and Objects for the available events. |
event_data |
object | The data for this event. See iPixel Events and Objects for the data to send. (Note: you do not need to send event_data with page_view.) |
All events require the event_name argument. Each event except for page_view also requires certain event_data, described in the event-specific sections below.
C. Passing Data to the iPixel¶
There are two ways to populate the event in GTM.
Method 1: Single GTM Variable
For each of the events that require event_data, iPixel recommends that you create a GTM Variable that is the payload. For example (where {{iPixel - Add To Cart}} is a GTM Variable you create):
<script>
InmobiPixel("track", "add_to_cart", {{iPixel - Add To Cart}});
</script>
Method 2: Composition of GTM Variables
You can also build the object composed of multiple variables. For example:
<script>
InmobiPixel("track", "add_to_cart", {
"currency": "USD",
"value": {{iPixel - Add To Cart - Value}},
"items": {{iPixel - Add To Cart - Items}}
});
</script>
GA4 Compatibility
iPixel is compatible with the Google Analytics 4 (GA4) API. If your Data Layer is configured to store data in GA4 format, you can pass those Data Layer Variables directly to the tag itself. For example, if {{GA - Ecommerce}} refers to the ecommerce field of your GA4-formatted Data Layer, pass it straight to the pixel:
<script>
InmobiPixel("track", "add_to_cart", {{GA - Ecommerce}});
</script>