> For the complete documentation index, see [llms.txt](https://knowledgebase.offer18.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://knowledgebase.offer18.com/zh/wang-luo/dian-shang-ji-cheng/woocommerce.md).

# WooCommerce

为了与 WooCommerce 集成，需要将 Offer18 图片像素放置在 WooCommerce（WordPress）中。 <br>

### [<mark style="color:蓝色;">获取图片像素</mark>](/zh/wang-luo/postback-ji-cheng.md)

***

## WooCommerce 集成

有两种方法将 Offer18 图片像素添加到 WooCommerce：-<br>

### 选项 1：WordPress 插件

可以使用 weDevs 的 WordPress 插件 “WooCommerce Conversion Tracking”。

要遵循的步骤：

1. 登录到 WordPress 管理仪表板。
2. 转到 “插件” 并搜索 “WooCommerce Conversion Tracking”。\ <br>

   <div align="left"><figure><img src="/files/8a6f4a22842397d2686e7d872f8f5e42aac01dd4" alt=""><figcaption><p><br></p></figcaption></figure></div>
3. 安装并激活 weDevs 的 “WooCommerce Conversion Tracking”。
4. 转到 Conversion Tracking（位于 WooCommerce 选项卡的子菜单）。
5. 启用 “Custom” 并将 Offer18 像素放置在 “Successful Order（成功订单）”。&#x20;

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

6. 转到 保存更改

可以使用插件提供的令牌接收动态值。\
例如：  **\&sale** (Offer18) 可以添加到包含以下内容的图片像素中 **{order\_subtotal}**

**带 sale 参数的示例图片像素**

```
<img src="https://example.o18.click/p?mid=000&t=i&gb=1&sale={order_subtotal}" width="0" height="0"> 
```

***

视频教程 - WooCommerce 集成

{% embed url="<https://youtu.be/cayaPMkNzBk>" %}

***

### 选项 2：自定义配置

可以配置 **Conversion Tracking 语法** 在 WordPress 的自定义配置中。Offer18 的 Conversion Tracking 语法如下所示。

#### **Conversion Tracking 语法**

```php
add_action('woocommerce_thankyou', 'custom_track_o18');

function custom_track_o18($order_id)
{
  $order_data = wc_get_order($order_id);
  $total_amount = $order_data->get_subtotal();
  $currency = $order_data->get_currency();
  $order_number = str_replace('#', '', $order_data->get_order_number());
  echo '<img src="https://[domain]/p?m=[account_id]&t=i&gb=1&sale=' . $total_amount . '&adv_sub1=' . $order_number . '&currency='. $currency.'" width="0px" height="0px">';
}
```

{% hint style="info" %}
**所需更改**\
\
在脚本中将 \[domain] 替换为跟踪域名，将 \[account\_id] 替换为用户账号 ID

例如

\[domain] = **example.o18.click**\
\[account\_id]  = **0000**
{% endhint %}

要遵循的步骤

1. 登录到 WordPress 管理仪表板。
2. 转到 外观 **»** 主题文件编辑器。
3. 打开 **functions.php** 文件。
4. 将 Offer18 的 Conversion Tracking 语法放入此文件中。

<figure><img src="/files/206a1af3d1ef48a6bc867352e61b0752be3fdaef" alt=""><figcaption></figcaption></figure>

5. 转到 “更新文件”。


---

# 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:

```
GET https://knowledgebase.offer18.com/zh/wang-luo/dian-shang-ji-cheng/woocommerce.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
