Shopify Integration
Set up Anacoic on your Shopify store in under 10 minutes
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)
Method 1: Theme Editor (Recommended)
The quickest way to install Anacoic on Shopify.
Step 1: Get Your Anacoic Snippet
- Log in to your Anacoic Dashboard
- Create a new gateway (or use existing)
- Go to the Installation tab
- Copy the One-Line snippet:
<script src="https://edge.anacoic.com/v1/ana.js"
data-gateway="YOUR_GATEWAY_ID"
data-emq="optimize"></script>
Step 2: Add to Shopify Theme
- In Shopify Admin, go to Online Store → Themes
- Click Customize on your active theme
- Click the Theme settings (gear icon) in the left sidebar
- Select Custom code or Custom CSS/JS (varies by theme)
- Paste your Anacoic snippet in the Head section
- Click Save
Step 3: Verify Installation
- Visit your store homepage
- Open browser DevTools (F12)
- Go to Network tab
- Filter for “anacoic” or “edge.anacoic”
- Refresh the page
- 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
- Go to Online Store → Themes → Edit code
- Find
layout/theme.liquid - Find the
<head>section - Paste your snippet right before
</head>:
<!-- Anacoic Tracking -->
<script src="https://edge.anacoic.com/v1/ana.js"
data-gateway="YOUR_GATEWAY_ID"
data-emq="optimize"></script>
- Click Save
Method 3: Google Tag Manager
If you already use GTM on your Shopify store.
Create the Tag
- Open Google Tag Manager
- Click Tags → New
- Name it “Anacoic Base Tracker”
- Tag Type: Custom HTML
- Paste your One-Line snippet
- Trigger: All Pages
- Save and Submit
Test in Preview Mode
- Click Preview in GTM
- Enter your store URL
- Check that the Anacoic tag fires on page load
Tracking Purchase Events
Ad platforms match a purchase to a person using the identifiers you send with it (match keys). Pass the customer data you collected at checkout, with consent.
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_{{ order.id }}', // same ID on browser and server events so platforms deduplicate
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 Settings → Checkout → Additional scripts:
<script src="https://edge.anacoic.com/v1/ana.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>
Sending Match Keys
| Match key | How it’s sent |
|---|---|
user.email from the customer object (hashed with SHA-256 at the edge) | |
| Phone | user.phone from the customer object, E.164 format |
| External ID | user.external_id: the Shopify customer ID |
| Meta browser ID (_fbp) | Captured automatically from the cookie |
| Meta click ID (_fbc) | Captured automatically from the cookie or the fbclid parameter |
| IP address and user agent | Added automatically at the edge |
| scores how well it can match your events (Event Match Quality) in Events Manager → Data sources → your dataset. Anacoic shows which match keys your events actually carry under Diagnostics → Signal quality. |
Optimal Implementation
anacoic.track({
event_name: 'Purchase',
user: {
email: '{{ customer.email }}',
phone: '{{ customer.phone }}',
external_id: '{{ customer.id }}'
},
custom_data: {
value: {{ order.total_price }},
currency: '{{ shop.currency }}'
}
});
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 one stable event ID per order
Give every event for the same order the same event_id, in the browser and on the server, so the platform can recognise the copies as one purchase:
event_id: 'order_{{ order.id }}'
Don’t add timestamps or random values to the ID: every copy then looks like a different purchase and gets counted twice.
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/ana.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
- Configure Meta CAPI integration
- Set up Agent Gateway for AI discoverability
- Add custom domain for maximum reliability
Getting Help
- Shopify-specific questions: Contact support
- General tracking help: See Troubleshooting