> For the complete documentation index, see [llms.txt](https://instag.gitbook.io/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://instag.gitbook.io/doc/cheng-shi-ma-zi-ding-an-zhuang/gou-wu-ju-zhui-zong/fan-li-91app-jia-ru-gou-wu-ju.md).

# 範例：91APP 加入購物車

<figure><img src="/files/6WuKndqkCn9e1uo6hY2p" alt=""><figcaption><p>91app 加入購物車</p></figcaption></figure>

## 新增變數

<figure><img src="/files/wXEW6BccNgUMXQ0tXUHK" alt=""><figcaption><p>新增變數</p></figcaption></figure>

### 加入購物車 product\_id

<figure><img src="/files/61zIEr5q71rWElWmyasO" alt=""><figcaption><p>加入購物車變數</p></figcaption></figure>

* 變數名稱：91app \[add\_to\_cart] prdouct\_id
* 變數類型：資料層變數
* 資料層變數名稱：eventModel.items.0.item\_id
* 按下「儲存」

### 加入購物車 product\_name

如上述新增變數步驟，再建立 product\_name 變數

* 變數名稱：91app \[add\_to\_cart] product\_name
* 變數類型：資料層變數
* 資料層變數名稱：eventModel.items.0.item\_name
* 按下「儲存」

### 加入購物車 product\_price

如上述新增變數步驟，再建立 product\_price 變數

* 變數名稱：91app \[add\_to\_cart] prdouct\_price
* 變數類型：資料層變數
* 資料層變數名稱：eventModel.items.0.price
* 按下「儲存」

### 加入購物車 product\_quantity

如上述新增變數步驟，再建立 product\_quantity 變數

* 變數名稱：91app \[add\_to\_cart] product\_quantity
* 變數類型：資料層變數
* 資料層變數名稱：eventModel.items.0.quantity
* 按下「儲存」

***

## 新增觸發條件

<figure><img src="/files/TbuQE6OXVBhYCVk2b9Ip" alt=""><figcaption><p>新增觸發事件</p></figcaption></figure>

<figure><img src="/files/W1Vtb989eJGyrVhmPSzt" alt=""><figcaption><p>加入購物車事件</p></figcaption></figure>

* 觸發名稱：91app\[add\_to\_cart] (可更改)
* 觸發條件類型：自訂事件
* 事件名稱：add\_to\_cart
* 按下「儲存」

***

## 新增代碼

<figure><img src="/files/TsPmKE7iTBfCefncuxWT" alt=""><figcaption><p>建立代碼</p></figcaption></figure>

<figure><img src="/files/ePXN3B2eVG83tWErZfG1" alt=""><figcaption><p>加入購物車追蹤代碼</p></figcaption></figure>

* 代碼名稱： \[91app] add\_to\_cart
* 代碼類型：自訂 HTML
* HTML：複製下面內容程式碼貼上

```javascript
<script>
if({{91app [add_to_cart] product_id}} !== undefined && {{91app [add_to_cart] product_id}} != ''){
	itg('event', 'product',{
	    'type':'add',
	    'id': {{91app [add_to_cart] product_id}},
	    'category': '',
	    'brand': '',
	    'tag': '',
	    'price': {{91app [add_to_cart] product_price}} * {{91app [add_to_cart] product_quantity}}
	});
}
</script>
```

* 觸發條件：91app\[add\_to\_cart]（ [#xin-zeng-chu-fa-tiao-jian](#xin-zeng-chu-fa-tiao-jian "mention") ）

按下右上角「儲存」按鈕後，點擊右上角「提交」並且「發布」即可生效。

#### 提醒

* 請先用「預覽」功能測試，確認「Tags Fired」是否有觸發成功
