# WebSDK

## **开始使用**

要开始使用 Offer18 的 Web SDK 进行追踪，需要在网站中添加一个 script 标签。

<mark style="color:紫色;">放置位置：页眉（所有页面）</mark>

{% code fullWidth="false" %}

```html
<script src="https://web-resources.offer18.net/sdk/web/WebSDK.js"></script>
```

{% endcode %}

***

用户必须将以下代码片段添加到除订单确认/订单成功（感谢页）之外的所有落地页中。

<mark style="color:紫色;">放置位置：页眉（所有页面）</mark>

```html
<script>
    window.Offer18WebSDK.initializeConversion('<YOUR-CLICK-ID-PARAMETER>');
</script>
```

添加脚本后，需要在感谢页/订单确认页中添加以下脚本

<mark style="color:紫色;">放置位置：感谢页/订单成功页（单页）</mark>

```html
<script>
    window.Offer18WebSDK.trackConversion({
        domain: '',
        accountId: '',
        offerId: '',
        coupon:'',
        postbackType: '', // 'iframe' or 'pixel'
        isGlobalPixel: false, // true or false
        iGamingCampaign: true, // true 或 false
        allowMultiConversion: false, // true or false
        conversionData: {
            event: '', // Event Name (Please specify the event)
            payout: '', // Payout Amount (Please specify the payout amount)
            sale: '', // Sale Amount (Please specify the sale amount)
            currency: '',
            adv_sub1: '',
            adv_sub2: '',
            adv_sub3: '',
            adv_sub4: '',
            adv_sub5: '',
        },
        userActivityData: {
            'ig-user-id': '',
            'ig-deposit-amount': '',
            'ig-bet-amount': '',
            'ig-win-amount': '',
            'ig-withdrawal-amount': '',
            'ig-bonus-amount': '',
            'ig-product-id': '', 
      }
    })
</script>
```

{% tabs %}
{% tab title="对象配置 - window\.Offer18WebSDK.trackConversion()" %}

1. **domain** （必填）：用户的回传域名。
2. **accountId** （必填）：用户的 Offer18 帐号 ID。
3. **offerId** （必填）：活动的 ID。
4. **coupon ：** 此处可使用优惠券代码
5. **postbackType** : 它可以是 `'iframe'` 或 `'pixel'`，默认值为 `'iframe'`.&#x20;
6. **isGlobalPixel** ：用户可以通过设置此项来配置全局像素 `true` ，默认值为 `false`.
7. **iGamingCampaign :** 用户可以通过设置此项来配置 iGaming 回传 `true` ，默认值为 `false`.&#x20;
8. **allowMultiConversion** ：用户可以通过设置此项来允许多次转化 `true` ，默认值为 `false`.&#x20;
9. **conversionData** ：该对象包含可用于从网络获取值的参数。
10. **userActivityData** : 此对象包含可用于跟踪 iGaming 用户活动数据的参数
    {% endtab %}
    {% endtabs %}

{% hint style="info" %}
**用户 ID** (ig-user-id) 在 iGaming 回传中必须传递
{% endhint %}

#### **示例代码**

```html
<script>
    window.Offer18WebSDK.trackConversion({
        domain: 'example.o18.link',
        accountId: '0000',
        offerId: '00000000',
        iGamingCampaign: true,
        userActivityData: {
            'ig-user-id': 'Customer12',
            'ig-deposit-amount': '12',
            'ig-bet-amount': '5',
            'ig-win-amount': '5',
            'ig-withdrawal-amount': '10',
            'ig-bonus-amount': '5'
            'ig-product-id': 'ludo12', 
      }
    });
</script>
```

***

## 调试模式

要在 SDK 中启用调试模式，可以在脚本内添加以下代码：

```html
<script>
    window.Offer18WebSDK.activateDebugMode();
</script>
```

启用调试模式可让用户获得有关 SDK 工作的更详细信息，包括任何错误或调试消息。


---

# 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://knowledgebase.offer18.com/zh/igaming/igaming-sdk/websdk.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.
