> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://helpdesk.ezmob.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# 通过搜索广告变现

Search 广告位为您提供一个可放置在网站上的搜索框。访客提交搜索后，与其搜索内容相关的广告会在新窗口中打开。Search 不在 **添加广告位** 列表中，因此由 EZmob 为您设置。

## 获取 Search 广告位

1. 打开 **网站与投放**。如果您的网站尚未添加，请先点击 **添加网站**。
2. 请您的客户经理为该网站创建 Search 广告位。
3. 广告位准备就绪后，会显示在 **您的投放** 选项卡中。

## 安装代码

1. 在 **您的投放** 选项卡中，点击该广告位上的代码图标（**查看脚本**）。
2. 在 **数据中心** 下，选择 **美国东部（纽约）** 或 **欧盟（阿姆斯特丹）**。
3. 点击 **复制脚本**。
4. 将代码粘贴到页面中希望显示搜索框的位置。

代码由一个搜索表单和一段简短的脚本组成：

```html
<form id='form' role='search'>
<input type='search' id='query' name='q'
placeholder='Search...'
aria-label='Search through site content' required>
<button>Search</button>
</form>
<script>
const f = document.getElementById('form');
const q = document.getElementById('query');
function submitted(event) {
event.preventDefault();
const url = 'https://xml.qualiclicks.com/redirect?feed=YOUR_FEED_ID&auth=YOUR_AUTH&query=' + q.value + '&url=YOUR_SITE_URL';
const win = window.open(url, '_blank');
win.focus();
}
f.addEventListener('submit', submitted);
</script>
```

- 您可以修改表单的样式及其占位文字（placeholder）。
- `feed`、`auth` 和 `url` 的值必须与您自己代码中的值完全一致。
- 每个页面只能使用一次该表单，因为其 ID（`form`、`query`）必须唯一。

## 截图

- *截图：投放选项卡中的 Search 代码视图，显示数据中心选择器和“复制脚本”按钮*

## 相关文章

- [如何将网站添加到 EZmob 进行变现](https://helpdesk.ezmob.com/zh/article/how-to-add-your-site-to-ezmob-for-monetization-10hgtet/)
- [如何创建广告位并获取广告标签](https://helpdesk.ezmob.com/zh/article/how-to-create-a-placement-and-obtain-your-ad-tag-1jjrdjs/)
- [如何检查您的广告代码（附示例）](https://helpdesk.ezmob.com/zh/article/how-to-check-my-ad-codes-examples-3ppo88/)
- [使用欧盟广告服务器降低延迟](https://helpdesk.ezmob.com/zh/article/decrease-latency-with-eu-ad-server-support-1997405/)