Shopify Integration

Set up Anacoic on your Shopify store in under 10 minutes

Shopify Integration Guide

This guide walks you through setting up Anacoic server-side tracking on your Shopify store. No coding required for basic setup.

Prerequisites

  • Shopify store (any plan)
  • Anacoic account
  • Meta Pixel ID (if tracking Facebook ads)

The quickest way to install Anacoic on Shopify.

Step 1: Get Your Anacoic Snippet

  1. Log in to your Anacoic Dashboard
  2. Create a new gateway (or use existing)
  3. Go to the Installation tab
  4. Copy the One-Line snippet:
<script src="https://edge.anacoic.com/v1/tracker.js"
        data-gateway="YOUR_GATEWAY_ID"
        data-emq="optimize"></script>

Step 2: Add to Shopify Theme

  1. In Shopify Admin, go to Online StoreThemes
  2. Click Customize on your active theme
  3. Click the Theme settings (gear icon) in the left sidebar
  4. Select Custom code or Custom CSS/JS (varies by theme)
  5. Paste your Anacoic snippet in the Head section
  6. Click Save

Step 3: Verify Installation

  1. Visit your store homepage
  2. Open browser DevTools (F12)
  3. Go to Network tab
  4. Filter for “anacoic” or “edge.anacoic”
  5. Refresh the page
  6. You should see a request to edge.anacoic.com/track

Method 2: Shopify Custom Liquid

For more control over where the tracker loads.

Add to Theme.liquid

  1. Go to Online StoreThemesEdit code
  2. Find layout/theme.liquid
  3. Find the <head> section
  4. Paste your snippet right before </head>:
<!-- Anacoic Tracking -->
<script src="https://edge.anacoic.com/v1/tracker.js"
        data-gateway="YOUR_GATEWAY_ID"
        data-emq="optimize"></script>
  1. Click Save

Method 3: Google Tag Manager

If you already use GTM on your Shopify store.

Create the Tag

  1. Open Google Tag Manager
  2. Click TagsNew
  3. Name it “Anacoic Base Tracker”
  4. Tag Type: Custom HTML
  5. Paste your One-Line snippet
  6. Trigger: All Pages
  7. Save and Submit

Test in Preview Mode

  1. Click Preview in GTM
  2. Enter your store URL
  3. Check that the Anacoic tag fires on page load

Tracking Purchase Events

To achieve high EMQ scores (8+), you need to pass customer data with purchase events.

Using Shopify’s dataLayer (Shopify Plus)

If you have Shopify Plus with checkout customization:

// On order confirmation page
anacoic.track({
  event_name: 'Purchase',
  event_id: '{{ order.id }}_' + Date.now(),
  user: {
    email: '{{ customer.email }}',
    phone: '{{ customer.phone }}'
  },
  custom_data: {
    value: {{ order.total_price | money_without_currency }},
    currency: '{{ shop.currency }}',
    transaction_id: '{{ order.id }}'
  }
});

Using Additional Scripts

For standard Shopify plans, add to SettingsCheckoutAdditional scripts:

<script src="https://edge.anacoic.com/v1/tracker.js"
        data-gateway="YOUR_GATEWAY_ID"
        data-emq="optimize"></script>
<script>
  // Wait for tracker to load
  setTimeout(function() {
    if (window.anacoic) {
      window.anacoic.track({
        event_name: 'Purchase',
        user: {
          email: '{{ order.email }}'
        },
        custom_data: {
          value: {{ order.total_price | divided_by: 100.0 }},
          currency: '{{ order.currency }}'
        }
      });
    }
  }, 1000);
</script>

Achieving High EMQ Scores

EMQ Score Breakdown

Data PointPointsHow to Pass
Email+2.5user.email from customer object
Phone+2.0user.phone from customer object
Facebook Browser ID+1.5Auto-captured from cookie
Facebook Click ID+1.5Auto-captured from URL
IP + User Agent+1.0Auto-captured at edge
External ID+1.0Shopify customer ID

Optimal Implementation

anacoic.track({
  event_name: 'Purchase',
  user: {
    email: '{{ customer.email }}',      // +2.5 points
    phone: '{{ customer.phone }}',      // +2.0 points
    external_id: '{{ customer.id }}'    // +1.0 point
  },
  custom_data: {
    value: {{ order.total_price }},
    currency: '{{ shop.currency }}'
  }
});
// Expected EMQ Score: 8.0-9.5

Common Shopify Issues

Issue: Events Not Firing

Solution: Check theme’s Content Security Policy

Some themes block external scripts. Add this to your CSP:

script-src 'self' https://edge.anacoic.com;
connect-src 'self' https://edge.anacoic.com;

Issue: Customer Data Not Available

Solution: Check liquid object availability

Not all customer data is available on all pages:

  • {{ customer }} - Only available when logged in
  • {{ order }} - Only available on order/confirmation pages
  • {{ checkout }} - Only available during checkout

Issue: Duplicate Events

Solution: Use unique event IDs

Always include a unique event_id:

event_id: '{{ order.id }}_' + Date.now()

Shopify-Specific Features

Automatic Customer Detection

The Anacoic tracker can auto-detect logged-in Shopify customers:

<script>
  window.anacoic_config = {
    gateway_id: 'YOUR_GATEWAY_ID',
    emq: 'optimize',
    auto_identify: true  // Detects Shopify customer object
  };
</script>
<script src="https://edge.anacoic.com/v1/tracker.js"></script>

Product View Tracking

Track product views for dynamic ads:

// On product page
anacoic.track({
  event_name: 'ViewContent',
  custom_data: {
    content_name: '{{ product.title }}',
    content_type: 'product',
    content_ids: ['{{ product.id }}'],
    value: {{ product.price | divided_by: 100.0 }},
    currency: '{{ shop.currency }}'
  }
});

Next Steps

  1. Configure Meta CAPI integration
  2. Set up Agent Gateway for AI discoverability
  3. Add custom domain for maximum reliability

Getting Help