> 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/sou-xun-zhui-zong/fan-li-waca-sou-xun.md).

# 範例：waca 搜尋

## 新增觸發條件

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

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

* 觸發名稱：Window Loaded Search
* 觸發條件類型：網頁瀏覽 - 視窗已載入
* 事件名稱：條件 Page Path 包含 /search
* 按下「儲存」

***

## 新增代碼

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

<figure><img src="/files/LcPMMdUgrj4wqyxqtO6R" alt=""><figcaption><p>搜尋追蹤碼</p></figcaption></figure>

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

```javascript
<script>
var path = window.location.pathname.split('/');
  
if(path !== undefined && path[1] !== undefined && path[1] == 'search' && path[2] != ''){
	var keywords 	= decodeURIComponent(decodeURIComponent(path[2]));
  
	if(keywords !== undefined && keywords != ''){
		itg('event', 'action',{
		    'type':   "search",             
		    'category': '',
		    'label': keywords,
		    'value': 0                    
		});
	}
}
</script>
```

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

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

#### 提醒

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