Pixfizz Knowledge Base
  • 👋Welcome to Pixfizz
  • Overview
    • 💡Getting Started Checklist
  • Installation to Ecommerce stores
    • Pixfizz Ecommerce
      • Setup Required Custom Fields
      • Setup Required Custom Types
      • Shopper FAQs
        • How to Add a Custom Font to my Site
      • Liquid Documentation
    • Shopify Ecommerce
      • 💫How to get started
      • 🛠️Shopify Installation
      • 🛠️Shopify Installation - Variable Pages
        • Add Saved Projects Functionality
      • Linking products to shopify
    • ETSY
      • Setting Up Listings in Pixfizz
      • Setting up SKU's in Etsy & Pixfizz
  • Production Management
    • What Output Options are there for Production?
    • Production PDF versions
    • Add Order Codes to Production Files
    • Add Dynamic Barcode
    • Add a QR Code Element
      • QR Code Content element substitutions
    • Receipt of Orders
    • Custom fulfillment folder name
    • Ability to provide file content directly in _additional_files.json
    • Add Trim Marks to Production Files
    • File Upload variants and template options
    • Film Processing
  • Fulfillment Partners
    • Request Access to a Catalog
    • Publishing Products from a Catalog to your Site
    • Change Background Color of Preview Images
    • Mixam
      • About Mixam
      • Get Started with Mixam
      • Product Catalog
      • Request a Print Sample from Mixam (optional)
      • Fullfilment of Mixam Products
      • Linking to Mixam API
    • Navitor
      • Product Catalog
    • LA Cameras
      • Product Catalog
  • eCommerce CMS
    • Setup Shipping Services
    • How to Setup Taxes
      • Setup Tax Exempt Users
    • Extra Fees
    • Custom Web Components
      • <px-image-upload>
      • <px-date-selector>
    • Import promocodes into Pixfizz admin
    • FAQ
      • Hide a page from Search Engine Crawls
    • Google Analytics & Google Tag Manager
      • Setup New Account
      • Setup eCommerce Events in Pixfizz CMS
  • PRODUCT SETUP & DESIGN
    • Product Pricing
    • How to Create Templates
      • XML Definition Parameters
      • XML Set Parameters
      • XML Page Parameters
      • PDF Layers
      • Define page break on Layflat spreads
      • Calendar Setup
        • Calendar Week Starting with Sunday
        • Calendar Week Starting with Monday
    • Setup Collections to Publish Products
      • How to add Filters to your Collections
    • File Artwork
    • MSP HUB content
      • Graduation Text Element Substitutions
    • Sample Templates
      • Photo Prints
      • Cards (Folded)
      • Canvas Prints
      • Framed Prints
      • Notebooks
      • Drinkware
      • Clothing
      • Photo Albums
      • Layflat Photo Albums
    • Designs
      • How to Build a Card - Part 1: Implement Design
      • How to Build a Card - Part 2: Add Design Flexibility with Substitutions
      • How to Build a Photo Album - Layouts
      • How to Build a Photo Album - Trim Marks on Cover & Page
      • Template Business Card EU
    • Template and Design Options
    • Help Guide for the Editor
    • User Editing Options
      • Standard Editor
      • PX Preview
  • Admin Guide
    • Domains
    • Setup reCAPTCHA
    • Analytics
    • 📪Dashboard
    • Orders
      • Orders
      • Abandoned Carts
      • Production Files
      • Projects
    • Users
      • Users
        • User Information
        • Merging Anonymous Users
        • Change Password
        • Custom Fields
        • Promocodes (Single User)
        • Last Orders
        • Projects
        • Galleries
        • Calendars
        • Addresses
      • Invites
    • Galleries
      • Galleries
      • Organize/Tag Galleries
      • Public galleries image source for upload dialog
    • Products
      • Products
      • Product Attributes
      • Templates
        • Designs
      • Collections
      • Fonts
      • Font Palettes
      • Color Palettes
      • Element Substitutions
        • Element substitutions on text variants replacing “Target Element Name”**
      • Calendars
      • Price Variables
    • Shipping
      • Shipping Services
        • Ranking Weight for Shipping Options
      • Packaging
      • Shipping Address of Origin
      • Taxes
      • Addresses
      • Liquid support for shipping formulas
    • Marketing
      • Promocodes
    • Website
      • Pages
      • Layouts
      • Snippets
      • Assets
      • Special Web Components
        • Date Selector Component
        • Dynamic Previews
    • Settings
      • General
        • Website Configuration
        • Domain Hosting
        • Facebook Integration
        • Instagram Integration
        • Dropbox Integration
          • Dropbox integration for upload dialog
        • API settings
        • Watermark
      • Email Notifications
        • Email Notification Settings
        • Order Pending Confirmation Email
        • Order Payment Confirmation Email
        • Order Shipped Email
        • Signup Email
        • Password Reset Email
        • Abandoned Cart Email
        • Refer A Friend Email
      • Design Tool
        • Name
        • Logo
        • Favicon
        • Brand Color
        • Page Title
        • Use New Editor
        • Autofill Button
        • Launch Into Autofill
        • Captions
        • Unedited Warning
        • Image Flip
        • Alignment Aids
          • Alignment highlights
        • Two Page Spread
        • Auto Cropping
        • Crop Bleed
        • Asymmetrical bleeds and margins
        • Image Effects
        • Image Rotation
        • Edit cut print projects
        • Placeholder Rotation
        • Image Borders
        • Background Colors
        • Border Radius
        • Image Size Overlay
        • Project Options
        • Display Price
        • Copy Shared Projects
        • Cut Print Mode
        • Multi-Image Uploader
        • Large Format / Wall-Art
        • Highlight Editable Elements
        • Use Mapped Preview
        • Homepage URL
        • Cart Page Name
        • Account Page Name
        • Upload Size Limit
        • Default Font
        • Default Font Palette
        • Default Font Size
        • Default Text Color Palette
        • Default Image Border Color Palette
        • Background Color Palette
        • Google Tag Manager ID
        • Image Sources
        • Categories
        • Quicksave Prompt Delay
        • Help URL
        • Resolution Warning
        • Text Cropping Warning
        • Multitext Custom Fields
        • Custom JS
        • Admin Custom JS
        • Custom CSS
        • Fill Multiple Placeholders with a Print
        • Auto-Generate Previews from Design Products
        • Shrink-to-Fit for px-Image-Upload
        • PDF Import Panel
      • Translations
      • OAuth
      • Documentation
    • Payment Gateways
      • Stripe Webhook for callbacks
      • PayU Money (India) Callback URL
  • Use Cases
    • 🎨For Designers
    • 🖥️For Developers
  • 🔗API
    • 🖼️Dynamic Design Previews
  • Setup GA4 eCommerce Analytics
  • 🌐SEO
  • Structured Data
    • Product Pages
    • Shop Pages: ItemList
  • INTEGRATIONS
    • Dropbox
    • Darkroom
    • Stamped.io
    • Shippo
      • Shippo Setup
    • Tracking Unlimited
      • Setup
      • Product Setup
        • Product Code
        • Product Options
        • Shipping Services
    • Syncovery
      • Installation
      • Profile Setup
      • DPOF Profile Setup
      • Scheduler
      • Advanced Workflow Automation
    • Indisposable
    • Klaviyo
  • Group 1
    • Form to update Order Status
Powered by GitBook
On this page
  • Setup eCommerce Events
  • view_item Event
  • add_to_cart Event
  • view_cart Event
  • begin_checkout Event
  • purchase Event
  1. eCommerce CMS
  2. Google Analytics & Google Tag Manager

Setup eCommerce Events in Pixfizz CMS

Only required if you are not using the Shopper Managed Storefront

PreviousSetup New AccountNextProduct Pricing

Last updated 4 months ago

Setup eCommerce Events

view_item Event

This script should be placed on a snippet or page that will be rendered for all products. For the Shopper storefront template, the product/design_now snippet has the script.

<script>
    dataLayer.push({ ecommerce: null });
    dataLayer.push({
    event: "view_item",
    ecommerce: {
        currency: "{{ website.currency_code }}",
        value: {{ product.price }},
        items: [
        {
          item_id: "{{ product.code }}",
          item_name: "{{ product.name }}",
          index: 0,
          item_brand: "{% snippet 'website/brand' %}",
          item_category: "{% if product.custom.google_category != blank %}{{ product.custom.google_category | escape_json }}{% else %}{{ product.category | escape_json }}{% endif %}"
        }
        ]
      }
    });
</script>

add_to_cart Event

This is one of the more challenging scripts to deal with as there are multiple places where an end user can add a product to the cart. On the Shopper storefront template, there are 3 locations to manage:

Design Tool

The below script needs to be in a dedicated editor-scripts.js page that has no Layout assigned to it, needs to be referenced in the Custom JS field on any Design Tool Configuration(s) that is/are live and need to be tracked. Be sure to also have the correct GTM ID on the Design Tool Configurations.

Be sure to change the currency, if it is not a USD storefront.

window.addEventListener("DOMContentLoaded", () => {
    mobx.when(() => editor.store.project.loaded, async () => {
        const product = await fetch(`/v1/products/${editor.store.project.product_id}.json`).then(r => r.json());
        const theme = await fetch(`/v1/themes/${editor.store.theme_id}.json`).then(r => r.json());

        document.querySelector(".px-cart-button").addEventListener("click", function () {
            dataLayer.push({
                event: "add_to_cart",
                ecommerce: {
                    currency: "USD",
                    value: product.starting_price,
                    items: [
                        {
                            item_id: `${theme.code}:${product.code}`,
                            item_name: `${theme.name} ${product.name}`,
                            index: 0,
                            item_category: product.custom.google_category || product.category,
                            price: editor.store.price,
                            quantity: 1
                        }
                    ]
                }
            });
        });
    });
});

account-saved-projects Page

The icon to add a project to the cart needs the following parameter code:

onclick="dataLayer.push({ event: 'add_to_cart', ecommerce: { currency: '{{ website.currency_code }}', value: '{{ product.price | escape }}', items: [{ item_id: '{{ product.code | escape }}', item_name: '{{ product.name | escape_json }}', index: 0, item_brand: '{{ website.title }}', item_category: '{% if product.custom.google_category != blank %}{{ product.custom.google_category | escape_json }}{% else %}{{ product.category | escape_json }}{% endif %}', price: '{{ product.price | escape }}', quantity: '{{ product.min_quantity }}' }] } });"

design_now Snippet

The button to submit the project_create form on the product/design_now snippet requires the following parameter code:

onclick="dataLayer.push({ event: 'add_to_cart', ecommerce: { currency: '{{ website.currency_code }}', value: '{{ product.price | escape }}', items: [{ item_id: '{{ product.code | escape }}', item_name: '{{ product.name | escape_json }}', index: 0, item_brand: '{{ website.title }}', item_category: '{% if product.custom.google_category != blank %}{{ product.custom.google_category | escape_json }}{% else %}{{ product.category | escape_json }}{% endif %}', price: '{{ product.price | escape }}', quantity: '{{ product.min_quantity }}' }] } });"

view_cart Event

Add the following script to the cart Page.

{% assign line_item_count = 0 %}
<script>
    dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
    dataLayer.push({
    event: "view_cart",
    ecommerce: {
    currency: "{{ website.currency_code }}",
    value: {{ cart.total | minus: cart.shipping }},
    items: [
    {%- for orderline in cart.orderlines %}
    {
      item_id: "{{ orderline.product.code | escape }}",
      item_name: "{{ orderline.product.name | escape}}",
      coupon: "{{ cart.promocode_code | escape }}",
      discount: {{ cart.discount }},
      index: {{ line_item_count }},
      item_brand: "{% snippet 'website/brand' %}",
      item_category: "{%- if orderline.product.custom.google_category != blank %}{{ orderline.product.custom.google_category | escape_json }}{% else %}{{ orderline.product.category | escape_json }}{%- endif %}",
      price: {{ orderline.price }},
      quantity: {{ orderline.quantity }}
    }{%- if forloop.last == false %},{%- endif %}
    {%- assign line_item_count = line_item_count | plus: 1 %}{%- endfor %}
    ]
  }
});
</script>

begin_checkout Event

Just above the Proceed to Checkout button add this code:

{% assign item_count = 0 %}

Add the following code as a parameter on the Proceed to Checkout button:

onclick="dataLayer.push({ event: 'begin_checkout', ecommerce: { currency: '{{ website.currency_code }}', value: '{{ cart.total | minus: cart.shipping }}', items: [{%- for orderline in cart.orderlines %}{ item_id: '{{ orderline.product.code | escape }}', item_name: '{{ orderline.product.name | escape_json }}', coupon: '{{ cart.promocode_code | escape }}', discount: {{ cart.discount }}, index: {{ item_count }}, item_brand: '{% snippet 'website/brand'%}', item_category: '{% if orderline.product.custom.google_category != blank %}{{ orderline.product.custom.google_category | escape_json }}{% else %}{{ orderline.product.category | escape_json }}{% endif %}', price: '{{ orderline.price | escape }}', quantity: '{{ orderline.quantity }}' }{%- if forloop.last == false %},{%- endif %}{% assign item_count = item_count | plus: 1 %}{%- endfor %}] } });"

purchase Event

Add the following code to the payment_success page, or the page the end user will land on when successfully completing an order.

<script>
    dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
    dataLayer.push({
      event: "purchase",
      ecommerce: {
        transaction_id: "{{ order.code }}",
        value: {{ order.total }},
        tax: {{ order.tax }},
        shipping: {{ order.shipping }},
        currency: "{{ website.currency_code }}",
        coupon: "{{ order.promocode_code }}",
        items: [
        {%- assign item_count = 0 %} 
        {%- for orderline in order.orderlines %}
        {
          item_id: "{{ orderline.product.code }}",
          item_name: "{{ orderline.product.name }}",
          {%- if order.discount != 0 %}discount: {{ order.discount }},{% endif %}
          index: {{ item_count }},
          item_brand: "{{ website.title }}",
          item_category: "{% if orderline.product.custom.google_category != blank %}{{ orderline.product.custom.google_category | escape_json }}{% else %}{{ orderline.product.category | escape_json }}{% endif %}",
          price: {{ orderline.price }},
          quantity: {{ orderline.quantity }}
        }{%- assign item_count = item_count | plus: 1 %}{%- if forloop.last == false %},{%- endif %}
        {%- endfor %}
        ]
      }
    });
</script>

Please note for the tax object. If you are a non-US storefront you want to replace the {{ order.tax }} code above with the following code and ensuring that you update the 1.15 with the correct VAT rate. 1.15 would be 15%.

{{ order.total | divided_by: 1.15 | minus: order.total | times: -1 | round: 2 }}

The DesignTool

SavedProjects page

snippet for static products or design products that can be added straight to cart

view_item
add_to_cart
view_cart
begin_checkout
purchase
product/design_now