How to Track "Add to Cart" Events in Shopify with ZEPIC

Created by Naveen V, Modified on Thu, 3 Jul at 9:31 AM by Naveen V

Transform your Shopify store into a behavioral analytics powerhouse by implementing real-time "Add to Cart" tracking with ZEPIC. This integration provides instant visibility into customer shopping patterns, enabling you to optimise targeting, personalisation, and retention strategies.


Overview

This guide walks you through a two-step process to connect ZEPIC's tracking capabilities with your Shopify store. You'll learn how to identify logged-in customers and implement automated cart tracking that feeds real-time data directly into your ZEPIC dashboard.


Prerequisites

Before you begin, ensure you have:

  • Admin access to your Shopify store
  • Customer login functionality is enabled in your store settings
  • Shopify Admin API Access Token
  • Basic familiarity with Shopify's theme editor


Step 1: Identify Logged-In Customers Using Liquid

Customer identification is the foundation of behavioural tracking. This step configures your store to automatically pass customer email addresses to ZEPIC when users are logged in.


  1. Access Your Shopify Admin Panel
    • Log in to your Shopify Admin dashboard
    • Navigate to Online Store > Themes
  2. Edit Your Theme Code
    • Click Actions > Edit Code
    • Locate and open the theme.liquid file from the file list
  3. Insert the Identification Script
    • Scroll to the very bottom of the theme.liquid file
    • Find the closing </body> tag
    • Paste the following code snippet just before the </body> tag:


<script>
var email = "{{customer.email}}";
console.log("User Email", email);
if(email) {
    window.setTimeout(function() {
        window.zepic.identify("email", email);
    }, 10000);
}
</script>
  1. Save Your Changes
    • Click Save to apply the modifications


How It Works

This script captures the customer's email address when they're logged in and transmits it to ZEPIC after a 10-second delay. The delay ensures that ZEPIC's main tracking library has sufficient time to load before the identification call is made.


Important: Customer login must be enabled in your store settings for this functionality to work correctly.


Step 2: Load ZEPIC's Add to Cart Script

The second step implements the actual cart tracking functionality using Shopify's ScriptTag API. This automatically loads ZEPIC's tracking script across your entire store.

  1. Prepare Your API Credentials
    • Obtain your Shopify Admin API Access Token
    • Note your store domain (format: yourstore.myshopify.com)
  2. Execute the API Call: Run the following cURL command, replacing the placeholder values:


bash
curl -XPOST \
  -H "content-type: application/json" \
  -H "X-Shopify-Access-Token: <access_token>" \
  https://<store_domain>/admin/api/2025-01/script_tags.json \
  -d '{"script_tag":{"event":"onload","src":"https://au.zepiccdn.com/zepic_add_to_cart.js"}}'
  1. Replace These Values:
    • <access_token>: Your Shopify Admin API Access Token
    • <store_domain>: Your complete store domain (e.g., mystore.myshopify.com)


Alternative Methods

If you prefer not to use cURL, you can make this API call using:

  • Postman or a similar HTTP client
  • Your preferred programming language's HTTP library
  • Shopify's Admin API through their GraphQL or REST interfaces


Testing Your Setup


After implementing both steps, verify the integration works correctly:


  1. Log in to your store as a customer (not admin)
  2. Browse your product catalog and add items to your cart
  3. Check your ZEPIC dashboard for real-time activity data
  4. Verify customer identification by confirming that cart events are associated with the correct customer email


You should see add-to-cart actions appearing in your ZEPIC dashboard within seconds of customer interactions.


Implementation Summary

StepPurposeStatus
1Identify logged-in customers via emailRequired
2Load ZEPIC's cart tracking scriptRequired


Troubleshooting Tips

  • No data appearing? Check that customer login is enabled in your store settings
  • Identification not working? Verify that the script is placed correctly before the </body> tag
  • API call failing? Confirm your access token has the necessary permissions for ScriptTag creation
  • Script not loading? Check your browser's developer console for any JavaScript errors

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article