# その他のクロスドメイン設定方法

クロスドメインの設定は自動設定が基本ですが、うまく計測できない場合は、以下の方法をお試しください。

## 全手動設定

Ptengineの基本タグに以下を追加：

クロスドメイン計測用の特殊タグをサイトのソースコードに埋めていただく手順となります。

* Ptengineの基本タグに下記の 2 \~ 6 行目を追加する

  ![](/files/Jizx50CHvN60T0gjeqNO)

▼タグコピペ用

```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タグがたくさんあり、全てではなく特定のaタグからの遷移だけ計測したい場合、この方法をご利用ください。

* 方法２の設定方法と同様に、Ptengineの基本タグに下記の 12 \~ 16 行目を追加する

  ![](/files/rRzk35TiyaJUCOM6YUmY)

▼タグコピペ用

```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」を追加します。

  ![](/files/mt7BTDQHSdL0u3fMAIz8)

  ![](/files/zshWtwzAdgWcCFbOhVrP)

▼タグコピペ用

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

## **API連携**

遷移するボタンがaタグではなく、他の例えばformタグの場合、上記方法のいずれでも適用できません。API連携が必要です。設定方法は下記をご参照ください。コーディングに詳しくない方はエンジニアにお任せすることをお勧めいたします。

**以下Ptengineの外部連携APIをボタンのクリックイベントのJavaScriptで設定すれば完了です。**

```
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)
```

### ✅ 設定完了の確認方法

クロスドメイン遷移後のURLに `#_pt_link=********` または `?_pt_link=********` が付与されていることを確認。

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

{% hint style="danger" %}
**重要ポイント**

* Experienceを利用していなくても自動設定は有効
* ONにするとInsightとExperience両方に適用（Insightの元設定は無効化）
* ONにしないとExperienceでは適用されない
  {% endhint %}


---

# Agent Instructions: 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:

```
GET https://helps.ptengine.com/faq/insight-setting/cross-domain-other.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
