Skip to main content
Skip table of contents

Shopify Custom Pixel

This version is currently in ALPHA. If you would like to use it, please contact our Helpdesk team!

What is the Shopify Custom Pixel

Shopify Custom Pixel is a feature that allows merchants to create and integrate custom tracking pixels on their Shopify store. These pixels help track specific events, user behavior, and conversions, providing valuable data for analytics and marketing purposes. Unlike standard pixels, custom pixels offer greater flexibility, enabling merchants to tailor their tracking to meet specific business needs or integrate with third-party services not natively supported by Shopify. This feature is particularly useful for advanced marketing strategies and detailed customer insights.

To get started swiftly, ensure you have the following prerequisites:

  • Shopify Site

  • JENTIS Account

  • at least one container within the JENTIS Account

Installation Steps

Shopify Store: Custom Pixel

  1. Log into your Shopify account.

  2. Navigate to Settings > Customer Events.

  3. Press Add custom pixel and define a good name f.e. JENTIS.

  4. Set the settings the following way:

image-20240814-130428.png
  1. Add in the Codeblock the following code:

CODE
window.jentis = window.jentis || {};
window.jentis.shopifyApp = window.jentis.shopifyApp || {};
window.jentis.shopifyApp.dcp = window.jentis.shopifyApp.dcp || {};

// Please adapt the DCP-Configuration to your needs!
window.jentis.shopifyApp.dcp.domain = "intercontinentalgrid.org";
window.jentis.shopifyApp.dcp.hash = "9sc4rl";
window.jentis.shopifyApp.dcp.short = "shopify-teststore-001";
window.jentis.shopifyApp.dcp.filehash = "gbujzl";
window.jentis.shopifyApp.dcp.environment= "live";

window.jentis.shopifyApp.analytics = window.jentis.shopifyApp.analytics || [];
window.jentis.shopifyApp.customerPrivacy = window.jentis.shopifyApp.customerPrivacy || [];
window.jentis.shopifyApp.createObservableArray = function(baseArray) {
    var observableArray = {
        array: baseArray,
        observers: []
    };
    
    observableArray.addObserver = function(observer) {
        this.observers.push(observer);
        for (var i = 0; i < this.array.length; i++) {
            observer(this.array[i]);
        }
    };
    
    observableArray.push = function() {
        var items = Array.prototype.slice.call(arguments);
        var result = Array.prototype.push.apply(this.array, items);
        for (var i = 0; i < this.observers.length; i++) {
            this.observers[i].apply(null, items);
        }
        return result;
    };
    
    return observableArray;
}

window.jentis.shopifyApp.customerPrivacy = window.jentis.shopifyApp.createObservableArray(window.jentis.shopifyApp.customerPrivacy);
window.jentis.shopifyApp.analytics = window.jentis.shopifyApp.createObservableArray(window.jentis.shopifyApp.analytics);

this.customerPrivacy.subscribe('visitorConsentCollected', (event) => {
    window.jentis.shopifyApp.customerPrivacy.push(event);
});

analytics.subscribe('all_events', (event) => {
  window.jentis.shopifyApp.analytics.push(event);
});

window.jentis.shopifyApp.loadJENTISScript = function() {
  (function (sCDN, sCDNProject, sCDNWorkspace, sCDNVers) {
    if (
      window.localStorage !== null &&
      typeof window.localStorage === "object" &&
      typeof window.localStorage.getItem === "function" &&
      window.sessionStorage !== null &&
      typeof window.sessionStorage === "object" &&
      typeof window.sessionStorage.getItem === "function"
    ) {
      sCDNVers =
        window.sessionStorage.getItem("jts_preview_version") ||
        window.localStorage.getItem("jts_preview_version") ||
        sCDNVers;
    }
    window.jentis = window.jentis || {};
    window.jentis.config = window.jentis.config || {};
    window.jentis.config.frontend = window.jentis.config.frontend || {};
    window.jentis.config.frontend.cdnhost =
      sCDN + "/get/" + sCDNWorkspace + "/web/" + sCDNVers + "/";
    window.jentis.config.frontend.vers = sCDNVers;
    window.jentis.config.frontend.env = sCDNWorkspace;
    window.jentis.config.frontend.project = sCDNProject;
    window._jts = window._jts || [];
    var f = document.getElementsByTagName("script")[0];
    var j = document.createElement("script");
    j.async = true;
    j.src = window.jentis.config.frontend.cdnhost + window.jentis.shopifyApp.dcp.filehash + ".js";
    f.parentNode.insertBefore(j, f);
  })("https://" + window.jentis.shopifyApp.dcp.hash + "." + window.jentis.shopifyApp.dcp.domain,window.jentis.shopifyApp.dcp.short,window.jentis.shopifyApp.dcp.environment, "_");
}

window.jentis.shopifyApp.userCookieHandler = window.jentis.shopifyApp.userCookieHandler || {};
window.jentis.shopifyApp.userCookieHandler.attempts = 0;
window.jentis.shopifyApp.userCookieHandler.maxAttempts = 10;
window.jentis.shopifyApp.userCookieHandler.getCookieAndLoadScript = function() {
    browser.cookie.get("_shopify_y").then(function(value) {
        window.jentisApp = window.jentisApp || {};
        window.jentisApp.userId = value;

        if (value === "" && window.jentis.shopifyApp.userCookieHandler.attempts < window.jentis.shopifyApp.userCookieHandler.maxAttempts) {
            window.jentis.shopifyApp.userCookieHandler.attempts++;
            window.jentis.shopifyApp.userCookieHandler.getCookieAndLoadScript(); 
        } else {
            window.jentis.shopifyApp.loadJENTISScript();
        }
    });
};
window.jentis.shopifyApp.userCookieHandler.getCookieAndLoadScript();

The following values at the top must be replaced with the values from your container settings:

CODE
// Please adapt the DCP-Configuration to your needs!
window.jentis.shopifyApp.dcp.domain = "intercontinentalgrid.org";
window.jentis.shopifyApp.dcp.hash = "9sc4rl";
window.jentis.shopifyApp.dcp.short = "shopify-teststore-001";
window.jentis.shopifyApp.dcp.filehash = "gbujzl";
window.jentis.shopifyApp.dcp.environment= "live";

You can find your container settings in the JENTIS DCP under Settings > Containers.

image-20240814-135505.png
  1. Save the custom pixel.

JENTIS DCP: Install the Shopify Plugin

  1. Open your JENTIS DCP and navigate to Server Tag Manager > Plugins.

  2. Click on Add New Plugin.

  3. Select the Shopify Datalayer-Bridge.

  4. Define a good name and connect it to the right container.

JENTIS DCP: Connect the CMP-Bridge

  1. Open your JENTIS DCP and navigate to Legal Hub > Consentbars.

  2. Connect the Shopify CMP-Bridge with the container.

  3. Afterwards, open the corresponding vendors under Legal Hub > Vendors and edit there CMP-Settings.

    1. Predefined Vendor Categories are analytics, marketing and preferences.

Tracked Events by the Shopify Plugin:

The Shopify Plugin automatically tracks the following events:

  • pageview

  • search

  • cartview

  • productlist

  • productview

  • addtocart

  • removefromcart

  • checkout

  • order

This comprehensive tracking allows you to gain valuable insights into your Shopify store's performance.

Technical Information

Preview Mode

To run the preview mode, simply copy and paste your debug link from the preview session into the browser and execute it. After the page has loaded, remove all preview link URL parameters and reload the page. The preview is now loaded correctly. If not, please reload the page again once more.

To work with the Custom Events approach, it is essential that the _shopify_y cookie from Shopify is not blocked and is enabled by default. This first-party cookie is crucial for identifying users and managing requests within the Shopify system. All Custom Events rely on this cookie for proper functionality. The JENTIS system uses this ID to generate the user_id and to mitigate ITP restrictions, ensuring accurate tracking and data collection.

How to access the custom_event information?

We have added a property called 'shopify' to all JENTIS DataLayer commands. This property contains the original event information passed from Shopify. If certain information is not provided in the default JENTIS DataLayer, you can access the 'shopify' property to retrieve the necessary details yourself.

Q & A

Q: Can I access the payment method during checkout?

A: No, the payment method can only be accessed during the checkout_completed event.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.