> For the complete documentation index, see [llms.txt](https://docs.exoclick.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.exoclick.com/advertisers/zh/zhuan-hua-gen-zong/gen-zong-shou-ce/shopify-tracking.md).

# 如何使用 Shopify 跟踪转化

*本指南仅适用于 Shopify。如果您想了解转换跟踪的一般步骤，请查看* [*广告主部分*](/advertisers/zh/zhuan-hua-gen-zong/zhuan-hua-gen-zong.md)*.*

ExoClick 让您可以访问全球流量来源、定向功能、大数据和统计分析工具，以筛选结果并优化您的广告活动。本手册说明如何在 ExoClick 网络上跟踪您 Shopify 商店中的转化。

在本文档中，我们将提供两个事件跟踪示例：

* **checkout\_completed**
* **product\_added\_to\_cart**

在继续查看示例之前，请确保已在您的账户中创建 [**转化目标**](/advertisers/zh/zhuan-hua-gen-zong/zhuan-hua-gen-zong.md#creating-a-conversion-goal) 。

## 结账完成事件

如果您想使用 ExoClick Pixel 跟踪来追踪 Shopify 商店中的购买，您可以使用诸如 `checkout_completed`之类的事件。此事件会在访客完成购买时记录，并且每次结账仅触发一次。需要注意的是，在此示例中，转化目标的值是动态的。

要将 `checkout_completed` 事件添加到您的 Shopify 商店，请按以下步骤操作：

{% stepper %}
{% step %}
前往 **设置** 在您的 Shopify 管理面板中。
{% endstep %}

{% step %}
选择 **客户事件**.
{% endstep %}

{% step %}
点击 **添加自定义像素**.

<figure><img src="/files/4670ed6968f4640dbdf4af56197c7df8b122851a" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
设置 **营销权限** ，以符合 Cookies 政策的要求。

<figure><img src="/files/c2655af2faedf4e0cb88174d37ad7a57f01c3068" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
添加以下代码：

```javascript
analytics.subscribe('checkout_completed', (event) => {
  const el = document.createElement('script');
  el.setAttribute('src', 'https://a.magsrv.com/tag_gen.js');
  el.setAttribute('data-goal', 'XXXXX');
  const cost = event.data.checkout.subtotalPrice?.amount || event.data.checkout.totalPrice?.amount;
  el.setAttribute('data-value', cost);

  document.body.appendChild(el);
});
```

{% endstep %}

{% step %}
请务必将 `'XXXXX'` 替换为您自己的目标 ID。
{% endstep %}

{% step %}
最后，点击 **连接** 按钮。

<figure><img src="/files/b14336498f81f6fa35ef8b22a51dcf80e878d7a6" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

连接后，请使用 Shopify 的测试支付功能进行一次测试购买，以确认一切设置正确。

成功结账后，您应能在 ExoClick 管理后台的收入部分看到转化及记录的动态值。

{% hint style="info" %}
**注意：** 转化可能需要几分钟才会显示在您的 ExoClick 管理面板中。
{% endhint %}

<figure><img src="/files/4a20c7306514ed606d63628057c2d61259115242" alt=""><figcaption></figcaption></figure>

## 添加到购物车事件

该 `product_added_to_cart` 事件会在客户将商品添加到购物车时进行跟踪。需要注意的是，在此示例中，转化目标没有分配值。

要进行设置，请按照之前为 `checkout_completed` 事件概述的相同步骤操作。不过，请注意这次代码会有所不同。

* 添加以下代码：

```javascript
analytics.subscribe('product_added_to_cart', (event) => {
  const el = document.createElement('script');
  el.setAttribute('src', 'https://a.magsrv.com/tag_gen.js');
  el.setAttribute('data-goal', 'XXXXXX');

  document.body.appendChild(el);
});
```

* 请务必将 `'XXXXX'` 替换为您自己的目标 ID。
* 最后，点击 **连接** 按钮。

连接后，您可以通过将商品添加到购物车来测试设置。如果一切配置正确，您将在 ExoClick 管理面板中看到转化记录。

{% hint style="info" %}
**注意：** 转化可能需要几分钟才会显示在您的 ExoClick 管理面板中。
{% endhint %}

<figure><img src="/files/e67d7dbab70f41671f622a28d8d4ca1b65cab5dc" alt=""><figcaption></figcaption></figure>

## 其他事件设置

如果您想设置其他类型的事件，请参考 Shopify 手册 [Shopify 标准事件文档](https://shopify.dev/docs/api/web-pixels-api/standard-events).

{% hint style="warning" %}
**注意：** 这些事件是定制构建的。如果您想添加更多事件，请注意这将需要您自行进行开发。
{% endhint %}

如果您想查找有关 Shopify 像素的更多信息，请参阅此页面： [Shopify 像素文档](https://help.shopify.com/en/manual/promoting-marketing/pixels)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.exoclick.com/advertisers/zh/zhuan-hua-gen-zong/gen-zong-shou-ce/shopify-tracking.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
