# Shopify Integration

> The AnyTrack Shopify integration simplifies conversion tracking and attribution for eCommerce stores by automatically tracking purchases and key events, and sending data to platforms like Google Ads, Facebook Conversion API, and TikTok Ads.

<Prerequisites
  title="Before you begin"
  items={[
    { label: "You have an active AnyTrack account", done: true },
    { label: "You have admin access to your Shopify store", done: true },
    { label: "You can edit the Theme Liquid file in your Shopify theme", done: true },
    { label: "Your Shopify store is active and published", done: true },
  ]}
/>

## Shopify Integration Overview

The AnyTrack Shopify integration simplifies conversion tracking and attribution for your eCommerce store. With a straightforward installation process, it automatically tracks purchases and key events, sending data to platforms like Google Ads, Facebook Conversion API, and TikTok Ads. By using first-party data, AnyTrack improves Event Match Quality and ensures accurate attribution while maintaining privacy. This integration helps you build better audiences and improve marketing performance across multiple channels.

## How the Shopify AnyTrack Integration Works

1. **Traffic**: When visitors land on your website, AnyTrack collects traffic source data and First Party data.
2. **Customer Journey Tracking**: During the customer journey, AnyTrack automatically tracks events such as `ViewContent`, `AddToCart`, and `InitiateCheckout` through the AnyTrack Tracking Tag. 
   1. Collects and sends product data such as sku, price, quantity and name.
   2. Sends hidden tracking parameter to the cart object.
   3. Triggers the corresponding events such as `AddToCart` to the AnyTrack API which instantly forwards to your Ad Platform's Conversion API.
3. **Shopify Webhooks**: AnyTrack also receives customer journey events via Shopify Webhook notifications and sends them to the Ad Platforms' conversion API.
4. **Conversions:** When customers complete their `purchase`, AnyTrack processes the conversion data (including customer data and product data).
5. **Attribution:** AnyTrack processes the conversion data and reports it across various reporting sections of the AnyTrack Dashboard.
6. **Conversion API:** AnyTrack then sends your conversions to your **Ad Platforms' Conversion API** to feed your ad platform's Machine Learning, AI and automatic optimization with 100% of your conversion data.

### Technical Details

| Reference       | Value     | Information                                                                        |
| --------------- | :-------- | :--------------------------------------------------------------------------------- |
| Tracking Group  | `Shopify` | The Tracking Group reference can be used to activate <Glossary>AutoTag</Glossary>. |
| Subid Parameter | `atclid`  | The Subid Parameter used to pass the AnyTrack `click_id`.                          |
| Tracking Method | `Webhook` | -                                                                                  |

## Shopify Standard Customer Journey Events

AnyTrack automatically tracks standard eCommerce customer journeys and feeds the event data to your ad platforms so that you can create advanced behavioral audiences and improve attribution.

> 📘 **Note**
>
> Each ad platform integration has its own Event Mapping which AnyTrack handles automatically for you.

| Shopify           | AnyTrack           | Facebook           | Google Analytics 4                | Details                                    |
| :---------------- | :----------------- | :----------------- | :----------------- | :----------------------------------------- |
| `item_view`       | `ViewContent`      | `ViewContent`      | `view_item`        | When a visitor views a product.            |
| `cart/create`     | `AddToCart`        | `AddToCart`        | `add_to_cart`      | When a visitor adds a product to its cart. |
| `checkout/create` | `InitiateCheckout` | `InitiateCheckout` | `begin_checkout`   | When a visitor starts a checkout.          |
| `checkout/update` | `AddPaymentInfo`   | `AddPaymentInfo`   | `add_payment_info` | When a visitor adds its payment details.   |
| `orders/create`   | `Purchase`         | `Purchase`         | `purchase`         | When a visitor completes a purchase.       |

## Shopify Sends Conversions to AnyTrack Using Webhook Notifications

AnyTrack provides a pre-defined webhook that you can implement with your Shopify account.

```http Shopify webhook URL
https://t1.anytrack.io/hBtoE3hN/collect/Shopify
```

## Shopify Setup Guide

### Step 1: Add the AnyTrack Tag to Your Shopify Theme

1. Create a New Property in AnyTrack.
2. Set the Shop Name and URL (the root domain) and click Next.
3. Copy the AnyTrack Tracking Tag.
4. Open the Shopify Admin and Edit the Theme Code.
5. Select the Theme Liquid File and Paste the Tracking Tag in the `head` section.
6. Save the Theme Liquid file.

   <Video alt="Add the AnyTrack tracking tag to the Shopify theme" align="center" border={true} caption="Add the AnyTrack tracking tag to the Shopify theme" src={readmeAsset1} />

7. Use the [AnyTrack Pixel Helper](https://chromewebstore.google.com/detail/anytrack-pixel-helper/ojmhkmdpagjeopleoeihbhgejcfoijjn) Chrome extension to verify that AnyTrack has correctly installed the Tag.
8. Return to AnyTrack and adjust the property settings
   1. **Time Zone:** Match your shop time zone to avoid discrepancies.
   2. **The Base Currency:** Set the currency you want the dashboard to reflect. AnyTrack will convert any revenues into your base currency.
   3. **Client Side Tracking Settings:** Leave the default settings, which deliver optimal performance.

### Step 2: Add Shopify to Your AnyTrack Account

1. Go to the **[Integration Catalog](https://dashboard.anytrack.io/catalog)** and search for **Shopify**. Then click on the **Shopify card**.

   ![](./9c1d3d25a3d3d7d435a49a3d82bcff53c5cc50cf51d86ba702d15e87de54f59a-image-5f40e1f385.png)
2. Click on **Install Integration**.
   1. Fill the **Name** enter a name (e.g. MyShopify)
   2. Fill the URL of your shop or the Shopify admin login url and click **Create**

<Image align="center" className="border" border={true} src={readmeAsset2} />

### Step 3: Connect Your Shopify Customer Events

1. Copy the **Webhook URL** from the integration

   <Image align="center" className="border" border={true} src={readmeAsset3} />
2. Go to your Shopify **Admin Panel**
3. Navigate to **Settings >> Notifications**
4. Scroll down to the **Webhooks section** and click on "**Create webhook**"

   1. Select the events according to the list of required events:
   2. Leave the format as `JSON`
   3. Paste the Webhook
   4. Update the Webhook version to the **Latest**
   5. Click on "**Save webhook**"

   <br />

   > 📘 **Note**
   >
   > Repeat these steps for all (5) events listed on the Integration page.

   **Watch this video to add webhook notifications in Shopify:**

   <HTMLBlock html={"\n   <div style=\"position: relative; padding-bottom: 52.33333333333333%; height: 0;\"><iframe src=\"https://www.loom.com/embed/f000168bd01048ce80d18b575ddd3c0a?sid=a020a8ab-33ad-4232-982b-f7180e27886c\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%;\"></iframe></div>\n   "} />

   <br />

### Step 4: Connect Your Ad Platforms

Now that your shop connects with AnyTrack and tracks your customer journeys, you need to configure AnyTrack to send them to your Ad Platform's Conversion API such as Facebook, TikTok or Google Ads.

> 📘 **Note**
>
> The Facebook Ads integration occurs via the AnyTrack Dashboard and does not require any setup on the Shopify Admin.

<Video align="center" className="border" border={true} src={readmeAsset4} />

<br />

1. Navigate to **Tracking Tags**
2. Click on the Facebook Pixel Card
3. Click on the button Browse to connect to your Facebook Business Manager.
4. Select the Facebook Pixel and Facebook Manager
5. Click **Next**
6. Now click on Connect to open a connection with your Ad Account
7. Enable the Facebook Conversion API
8. Scroll down and Save.
9. Now Open the Ads Integration Tab (scroll up to the top of the screen)
10. Click on the UTM (Urchin Tracking Module) Tracking Template
11. Add the Template to your Facebook Ads

> 📘 **Note**
>
> Access other ad platform integrations to connect your other ad accounts.

> ❗ **Important**
>
> You must disconnect any other direct integrations that currently send conversions to your ad platforms or you will generate duplicate data in your ad accounts.

## Validate Your Integration

This section will enable you to validate the main aspects of your setup.

### Conversion Tracking

To validate your setup, wait for a conversion or trigger a test conversion yourself and inspect the conversion logs.

<Image alt="Inspect the Events Log to see the conversions arriving from Shopify." align="center" border={true} caption="Inspect the Events Log to see the conversions arriving from Shopify." src={readmeAsset5} />

**Shopify conversion payload example**

```json Shopify Webhook Data
{
  "id": 40881068146749,
  "created_at": "2024-08-25T21:11:38+00:00",
  "total_price": "27.72",
  "subtotal_price": "23.90",
  "total_tax": "3.82",
  "currency": "USD",
  "source_name": "web",
  "line_items": [
    {
      "title": "Cow Mug Custom Message",
      "variant_title": "11oz / Black",
      "price": "11.95",
      "quantity": 1,
      "sku": "24675843150437141759",
      "properties": {
        "_atclid": "mYC8t8gvBdZ2ZmWOf5Jm2hP9gptNB4UEgx"
      }
    }
  ],
  "note_attributes": [
    {
      "name": "__atclid",
      "value": "mYC8t8gvBdZ2ZmWOf5Jm2hP9gptNBCIGGr"
    }
  ],
  "x-Shopify-shop-domain": "0ae3b8-c6.myshopify.com",
  "x-Shopify-topic": "checkouts/create",
  "x-Shopify-api-version": "2024-07"
}
```

## Troubleshooting

> 📘 **Note**
>
> Based on thousands of integrations with Shopify, if you've followed the instructions and applied the default integration settings, you will not experience issues.

If you encounter issues, check the following:

1. Verify the AnyTrack tag is in the `head` section of your shop
2. If you're on the Free plan, check the monthly traffic limit in the billing section
3. The Free plan does not include Conversion API for ad platforms
4. Confirm you've followed the default integration settings
5. Install the [AnyTrack Pixel Helper](https://chromewebstore.google.com/detail/anytrack-pixel-helper/ojmhkmdpagjeopleoeihbhgejcfoijjn) Chrome extension to verify the tag is active

<FaqAccordion
  title="Shopify Integration - Frequently Asked Questions"
  icon="fa-duotone fa-circle-question"
  items={[
    {
      question: "Can I import past conversions into AnyTrack?",
      answer: "No. AnyTrack can only ingest conversions that have been triggered following a visitor session on your website. Historical orders placed before the integration was installed cannot be imported."
    },
    {
      question: "How do I prevent the AnyTrack click ID from displaying in the cart line items?",
      answer: "Per Shopify documentation, any line item property beginning with an underscore (e.g., _atclid) is hidden from customers at checkout. If your theme does not follow this convention and the _atclid value appears during checkout, follow the instructions in the Remove Line Item Properties guide to adjust your theme code."
    },
    {
      question: "The conversion name is not what I am expecting. How do I change it?",
      answer: "You can update the Event Mapping in the Integration page. However, this is not recommended as the standard events are already mapped to the corresponding standard events in your ad platforms. Only change the mapping if you understand the impact on your ad platform event manager."
    },
    {
      question: "Why are there discrepancies between Shopify and AnyTrack?",
      answer: "Differences between Shopify Analytics and AnyTrack are normal across all analytics platforms. Factors include how sessions are defined, whether visitors allow cookies and JavaScript, browser extensions blocking tracking, and different reporting time zones. AnyTrack uses both client-side and server-side tracking to maximize data collection accuracy."
    },
    {
      question: "What errors appear in the integration logs?",
      answer: "Tracking errors can occur when visitors block JavaScript or prevent Tracking Tags from loading. Check that the AnyTrack tag is in the head section of your shop, verify your plan limits in the billing section, and confirm you followed the default integration settings."
    }
  ]}
/>

---

## Related Resources

- [Pixel Helper Extension](/docs/anytrack-chrome-extension)
- [Install AnyTrack Tag](/docs/install-anytrack-tag)
- [Integration Event Log](/docs/integration-event-log)
