> For the complete documentation index, see [llms.txt](https://docs.exoclick.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.exoclick.com/advertisers/zh/guang-gao-huo-dong/third-party-adserving.md).

# 第三方广告投放

第三方广告投放允许广告主使用自己的服务器来托管、投放并跟踪事件，而不是完全依赖 ExoClick 来执行这些任务。在活动层级上，这通过利用以下方式实现 **HTML 横幅标签** 和 **iframe URL**.

HTML 横幅标签和 iframe URL 的一些优势在于，大多数重复性的活动更新，例如更改和更新创意，都可以直接在广告主自己的服务器上完成。此外，这种方式还有助于自动化，使跟踪、A/B 测试和分群等任务更易管理。

## 将 HTML 横幅标签或 iframe URL 插入活动中

如果 **HTML / iframes** 已在你的账户中启用，请前往 **第2步 - 广告** 在你的活动创建窗口中。然后选择 HTML Banners 或 iframe URL，并点击 **+ 广告变体** 按钮，将标签或 URL 添加到你的活动中。

目前，ExoClick 使用 **HTML 横幅** 标签用于 **所有横幅格式**，以及 **iframe URL** 用于 **插屏广告** 和 **原生广告**.

HTML 横幅会接受 HTML 标签作为输入。你可以直接在输入框中使用 HTML 标签创建你的创意，也可以添加一个指向你主机页面的 iframe：

<figure><img src="/files/9d0bfbb2a59058722cee1134014f40ddcfe7e1f9" alt=""><figcaption></figcaption></figure>

使用 iframe URL 时，你只需提供 iframe 的源地址：

<figure><img src="/files/0a72ffeb3de685283067db17b25e4965c0d302c6" alt=""><figcaption></figcaption></figure>

## 在 HTML 活动中记录点击和转化

由于 HTML Banner 和 Iframe URL 活动通过第三方服务器投放，管理面板默认不会记录任何 ***点击*** 或 ***转化*** 转化。如果你想跟踪这些事件，需要按以下步骤操作：

### 步骤 1：将 {click\_url} 和 {conversions\_tracking} 参数添加到你的 HTML/iFrame 代码中

将 {click\_url} 和 {conversions\_tracking} 添加到广告标签中，如下例所示：

```js
<body style="margin: 0px"><iframe id='a628d52a' name='a628d52a' src='https://ad.third-party-server.com/iframe?tag={conversions_tracking}&click_url={click_url}' frameborder='0' scrolling='no' width='300' height='250'></iframe></body>
```

### 步骤 2：在你的主机页面中添加用于检测 {click\_url} 值的代码

你的主机页面需要能够检测 {click\_url} 值，以便生成点击，并检测 {conversions\_tracking} 字符串，以便在管理面板中记录转化。获取这些值的方式取决于你主机页面所使用的编程语言。以下是一些示例：

**JavaScript：**

```js
<div id="anchor"></div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script type="text/javascript">
//从 iframe URL 获取参数
function paramFetch(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
  results = regex.exec(location.search);
  return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
//创建横幅
  var tag = paramFetch('tag');
  var clickid = paramFetch('click_url');
  if (!clickid.endsWith(';')) {
            clickid += ';';
        }
  var link = document.createElement('a');
  link.href = clickid + 'https://www.mylandingpage.com?tag=' + tag ;
  link.target = '_blank';
  link.innerHTML = '<img src=\"banner300x250.jpg\">';
  document.getElementById('anchor').appendChild(link);
</script>
```

在此脚本中，只要你指定这个值前面的 URL 参数，就可以添加任何你可能需要通过 iframe 跟踪的变量。例如，如果你想跟踪 **子ID**，你可以使用以下代码：

```js
<div id="anchor"></div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script type="text/javascript">
//从 iframe URL 获取参数
<script type="text/javascript">
function paramFetch(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
  results = regex.exec(location.search);
  return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
  var tag = paramFetch('tag');
  var subid = paramFetch('subid'); //从 URL 中获取 'subid' 参数的值
  var link = document.createElement('a');
  link.href= 'https://www.mylandingpage.com?tag=' + tag + '&subid=' + subid ; //跟踪 subid 参数
  link.target= '_blank';
  link.innerHTML = '<img src=\"banner300x250.jpg\">';
  document.getElementById('anchor').appendChild(link);
</script>
```

Sub ID 跟踪是一种为你的链接添加额外信息的方法，这样你就能更好地了解网站流量的来源。通过在 URL 中添加 Sub ID 参数，你可以跟踪特定细节，例如哪个广告、哪个平台或哪个活动为你的网站带来了访客。

**PHP：**

```php
<?php
$tag_tracker = isset($_GET['tag']) ? $_GET['tag'] : '';
$click_url = isset($_GET['click_url']) ? $_GET['click_url'] : '';
?>

if (substr($click_url, -1) !== ';') {
  $click_url .= ';';
}

<a target="_blank" href='<?php echo $click_url ?>https://ad.third-party-server-ad.com/click?tag=<?php echo $tag_tracker ?>' >
```

链接的最终结果应为：

```js
{click_url}https://ad.third-party-server-ad.com/click?tag={conversions_tracking}
```

当用户点击此广告时，我们的服务器会自动移除 {click\_URL} 值并将访客重定向到该页面，同时记录点击并提供转化详情。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.exoclick.com/advertisers/zh/guang-gao-huo-dong/third-party-adserving.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
