> 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-mai-zhui-zong/fan-li-easystore-song-chu-ding-dan.md).

# 範例：Easystore 送出訂單

## 新增變數

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

### 購物商品

<figure><img src="/files/l3t5h7McrAe3Ue0oZydK" alt=""><figcaption><p>購物商品變數</p></figcaption></figure>

* 變數名稱：easystore \[purchase]
* 變數類型：資料層變數
* 資料層變數名稱：eventModel
* 按下「儲存」

***

## 新增觸發條件

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

<figure><img src="/files/rQp5CtJ7deshZLRad3VN" alt=""><figcaption><p>購買事件</p></figcaption></figure>

* 觸發名稱：easystore\[purchase] (可更改)
* 觸發條件類型：自訂事件
* 事件名稱：purchase
* 按下「儲存」

***

## 新增代碼

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

<figure><img src="/files/qMr8qx2ywPTdgKkduVs6" alt=""><figcaption><p>送出訂單代碼</p></figcaption></figure>

* 代碼名稱： \[easystore] purchase
* 代碼類型：自訂 HTML
* HTML：複製下面內容程式碼貼上

```javascript
<script>
var purchase = {{easystore [purchase]}};
  
if(purchase !== undefined){
    var data = {
	  'id': purchase.transaction_id,
	  'user_id':'',
	  'product': '',
	  'amount': purchase.value
    };
  
    var items = purchase.items;
  
	for(var i in items){
		if(items[i].item_id !== undefined){
			data.product += (data.product == '')? items[i].item_id : ',' + items[i].item_id;
		}
	}

    setTimeout(function() {
      itg('event', 'purchase',{
		    'id':   data.id,             
		    'price': data.amount,
		    'promotion': '',
		    'product': data.product
		});
    }, 500);
}
</script>
```

* 觸發條件：easystore\[purchase]（ [#xin-zeng-chu-fa-tiao-jian](#xin-zeng-chu-fa-tiao-jian "mention")）

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

#### 提醒

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