# 範例：91APP 搜尋

## 新增變數

<figure><img src="https://2075385674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA8vmX591TX7ccV7n1Qcw%2Fuploads%2F8ZpdLCrZmX9WeDFTjaSz%2Fimage.png?alt=media&#x26;token=aa68aa9d-e4d0-4c01-9a9a-4ece53fa9971" alt=""><figcaption><p>新增變數</p></figcaption></figure>

### 搜尋關鍵字

<figure><img src="https://2075385674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA8vmX591TX7ccV7n1Qcw%2Fuploads%2F0rQgdzBrRXb7TeqrMllf%2Fimage.png?alt=media&#x26;token=7da51efd-c017-41c6-b358-aa59ffdb26cc" alt=""><figcaption><p>搜尋關鍵字變數</p></figcaption></figure>

* 變數名稱：91app \[search] term
* 變數類型：資料層變數
* 資料層變數名稱：eventModel.search\_term
* 按下「儲存」

***

## 新增觸發條件

<figure><img src="https://2075385674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA8vmX591TX7ccV7n1Qcw%2Fuploads%2FMXHIHY1kmVqRN1A9s79A%2Fimage.png?alt=media&#x26;token=1ab5a496-efaf-4fcc-a9c4-1a2bf5c69819" alt=""><figcaption><p>新增觸發事件</p></figcaption></figure>

<figure><img src="https://2075385674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA8vmX591TX7ccV7n1Qcw%2Fuploads%2FbYw13IIlvdGYjyVTzi1b%2Fimage.png?alt=media&#x26;token=cf099fee-e62a-4ebb-80f9-3429d8745967" alt=""><figcaption><p>搜尋事件</p></figcaption></figure>

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

***

## 新增代碼

<figure><img src="https://2075385674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA8vmX591TX7ccV7n1Qcw%2Fuploads%2FUfHMuXUYJnlpTHtIcitW%2Fimage.png?alt=media&#x26;token=07663b9e-0534-45de-8bfe-93b048cb3503" alt=""><figcaption><p>建立代碼</p></figcaption></figure>

<figure><img src="https://2075385674-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA8vmX591TX7ccV7n1Qcw%2Fuploads%2FB7r5umqZ1sBc4pYoH6On%2Fimage.png?alt=media&#x26;token=4e9d6af6-1793-4641-8b0f-2bcdae333114" alt=""><figcaption><p>搜尋追蹤碼</p></figcaption></figure>

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

```javascript
<script>
var keywords 	= {{91app [search] term}};

if(keywords !== undefined && keywords != ''){
	itg('event', 'action',{
	    'type':   "search",             
	    'category': '',
	    'label': keywords,
	    'value': 0                    
	});
}
</script>
```

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

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

#### 提醒

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