Nyla dataLayer

Overview

This document outlines the data layer logic and contents Nyla sites. This doc should be used to build out additional pixels in your Google Tag Manager (GTM) container or simply understand the data flow for the events on your Nyla site.
 

Page Views

Initial Page Load

When a user first loads a Nyla site, a page view is sent on the initialization event. This is a built-in GTM event. An example of that event is here:
dataLayer.push({event: "gtm.init"})

Subsequent Page View

Nyla is a single-page app (SPA). As such, we rely on virtual page view events to trigger page views for the second and subsequent page views of a user’s session. This page_view event includes the path of the page along with some custom, user dimensions.
Example:
dataLayer.push({
  event: "page_view",
  page: "/",
  visitorType: "Guest",
  customerEmail: "na", // PII and not passed to GA; used for marketing pixels
  customerFirstName: "na", // PII and not passed to GA; used for marketing pixels
  customerLastName: "na", // PII and not passed to GA; used for marketing pixels
  customerOrdersCount: 0,
  customerTotalSpent: 0
})

Ecommerce

Most e-commerce events take place on product listing pages (PLP), product detail pages (PDP), or checkout pages. However, if your Nyla site features products on other pages, such as the home page, e-commerce events will also fire.
Nyla currently supports the following Universal Analytics enhanced e-commerce events. Note that additional events in checkout and transactions are handled by Shopify.
The GA4 equivalents of the above events are also supported
See below for examples of the dataLayer for each of the e-commerce events outlined above.

Product Impressions (UA) / View Item List (GA4)

dataLayer.push({
  event: "gtmEvent",
  eventAction: "product impressions",
  eventLabel: "",
  eventCategory: "enhanced ecommerce",
  ecommerce: {
    currencyCode: "USD",
    actionField: {list: "New Products"},
    impressions: [
      {
        name: "Product Name",
        id: "1232",
        productId: "7441591828679",
        variantId: "42560682361031",
        shopifyId: "7441591828679",
        price: 48,
        brand: "Product Brand",
        position: 1,
        category: "Product Category",
        list: "New Products"
      },
      {
        name: "Product Name",
        id: "1041",
        productId: "6732600508615",
        variantId: "39949810237639",
        shopifyId: "6732600508615",
        price: 39,
        brand: "Product Brand",
        position: 2,
        category: "Product Category",
        list: "New Products"
      },
      {
        name: "Product Name",
        id: "1065",
        productId: "6776104288455",
        variantId: "40128382697671",
        shopifyId: "6776104288455",
        price: 39,
        brand: "Product Brand",
        position: 3,
        category: "Product Category",
        list: "New Products"
      }
    ]
  }
})

Product Clicks (UA) / Select Item (GA4)

dataLayer.push({
  event: "gtmEvent",
  eventAction: "product click",
  eventCategory: "enhanced ecommerce",
  eventLabel: "",
  ecommerce: {
    currencyCode: "USD",
    click: {
      actionField: {list: "List Name", action: "click"},
      products: [
        {
          name: "Product Name",
          id: "1126",
          productId: "7203712270535",
          variantId: "41621041709255",
          shopifyId: "7203712270535",
          price: 34,
          brand: "Product Brand",
          variant: "Product Variant",
          category: "Product Category",
          position: 2
        }
      ]
    }
  }
})

Product Detail Views (UA) / View Item Details (GA4)

dataLayer.push({
  event: "gtmEvent",
  eventAction: "product detail view",
  eventLabel: "",
  eventCategory: "enhanced ecommerce",
  variantCompareAtPrice: null,
  variantPrice: 34,
  variantInventoryQuantity: 1887,
  ecommerce: {
    currencyCode: "USD",
    detail: {
      products: [
        {
          name: "Product Name",
          id: "1126",
          productId: "7203712270535",
          variantId: "41621041709255",
          shopifyId: "7203712270535",
          price: 34,
          brand: "Product Brand",
          variant: "Product Variant",
          category: "Product Category"
        }
      ]
    }
  }
})

Product Add to Cart (UA) / Add to Cart (GA4)

dataLayer.push({
  event: "gtmEvent",
  eventCategory: "enhanced ecommerce",
  eventAction: "add to cart",
  eventLabel: "",
  ecommerce: {
    currencyCode: "USD",
    add: {
      actionField: {list: "Product List", action: "add"},
      products: [
        {
          name: "Product Name",
          variant: "Product Variant",
          id: "1126",
          productId: "7203712270535",
          variantId: "41621041709255",
          category: "Product Category",
          brand: "Product Brand",
          price: 34,
          quantity: 1
        }
      ]
    }
  }
})

Product Remove from Cart (UA) / Remove from Cart (GA4)

dataLayer.push({
  event: "gtmEvent",
  eventCategory: "enhanced ecommerce",
  eventAction: "remove from cart",
  eventLabel: "",
  ecommerce: {
    currencyCode: "USD",
    add: {
      actionField: {list: "Product List", action: "add"},
      products: [
        {
          name: "Product Name",
          variant: "Product Variant",
          id: "1126",
          productId: "7203712270535",
          variantId: "41621041709255",
          category: "Product Category",
          brand: "Product Brand",
          price: 34,
          quantity: 1
        }
      ]
    }
  }
})