> For the complete documentation index, see [llms.txt](https://helps.ptengine.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://helps.ptengine.com/cn/faq/insight-setting/cross-domain-other.md). Agents can also search and read this documentation through its [MCP server](https://helps.ptengine.com/~gitbook/mcp).

# 跨域配置方法

## 其他跨域配置方法 <a href="#other-cross-domain-configuration-methods" id="other-cross-domain-configuration-methods"></a>

跨域配置以自动配置为基础，但如果无法正确监测，请尝试以下方法。

## 完全手动配置 <a href="#full-manual-configuration" id="full-manual-configuration"></a>

向Ptengine基础代码添加以下内容：

需要在网站源代码中嵌入用于跨域监测的特殊标签。

将以下第2～6行添加到Ptengine基础代码中 ▼标签复制用

```javascript
<!-- Ptengine Tag -->
<script>
window._pt_sp_2 = [];
_pt_sp_2.push('setCrossDomainLink,allManual');
_pt_sp_2.push('setAccount,xxxxxxxx');
</script>
<script src="<https://js.ptengine.jp/xxxxxxxx.js>"></script>
<!-- End Ptengine Tag -->
※ 将xxxxxxxx替换为您的标签（sid）。
```

## **半手动配置** <a href="#semi-manual-configuration" id="semi-manual-configuration"></a>

当页面上有大量产生跨域的a标签，且您只想监测来自特定a标签的转移时，请使用此方法。

与方法2的配置方法类似，将以下第12～16行添加到Ptengine基础代码中 ▼标签复制用

```javascript
<!-- Ptengine Tag -->
<script>
window._pt_sp_2 = [];
_pt_sp_2.push('setCrossDomainLink,halfManual');
_pt_sp_2.push('setAccount,xxxxxxxx');
</script>
<script src="<https://js.ptengine.jp/xxxxxxxx.js>"></script>
<!-- End Ptengine Tag -->
※第14行的末尾必须是halfManual
```

**2** 在a页面上指向b页面的a标签（按钮）中添加“data-pt-crossDomain”属性，如下所示。 ▼标签复制用

```
<a href="<https://www.b.com>" data-pt-crossDomain>button</a>
```

## **API集成** <a href="#api-integration" id="api-integration"></a>

如果转移按钮不是a标签，而是其他标签（例如form标签），则无法使用上述任何方法。需要进行API集成。有关配置方法，请参见下文。建议不熟悉编码的人员由工程师处理。

**只需在按钮点击事件的JavaScript中设置以下Ptengine外部集成API即可完成配置。**

```
API：window.ptengine.createCrossDomainUrl
```

例如，如果要在按钮点击时转移到另一个网站，可以按如下方式使用Ptengine外部集成API进行配置。

```javascript
var btn = document.querySelector(".btn");
btn.addEventListener("click", function(){
    var targetUrl = '<https://www.b.com>';
    var openUrl = window.ptengine && window.ptengine.createCrossDomainUrl && typeof window.ptengine.createCrossDomainUrl === 'function' && window.ptengine.createCrossDomainUrl(targetUrl);
    window.open(openUrl)
},false)
```

### ✅ 配置完成确认方法 <a href="#how-to-confirm-configuration-completion" id="how-to-confirm-configuration-completion"></a>

确认跨域转移后的URL中添加了`#_pt_link=********`或`?_pt_link=********`。

例：`https://www.b.com#_pt_link=_s_gEjf3wNa5RNxgw4lC5H8Eg...`
