# WebSDK

## **Get started**

To start tracking with Offer18's web SDK, one needs to add a script tag in the website.

<mark style="color:purple;">Placement : Header (All Pages)</mark>

{% code fullWidth="false" %}

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

{% endcode %}

***

Users must add the following code snippet into all landing pages except Order confirmation / Order Success (Thank you) page.

<mark style="color:purple;">Placement : Header (All Pages)</mark>

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

After adding the script one needs to add the following script in thankyou/order-confirmation page

<mark style="color:purple;">Placement : Thank you Page/Order Success Page (One Page)</mark>

```html
<script>
    window.Offer18WebSDK.trackConversion({
        domain: '',
        accountId: '',
        offerId: '',
        coupon:'',
        postbackType: '', // 'iframe' or 'pixel'
        isGlobalPixel: false, // true or false
        iGamingCampaign: true, // true or 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="Object Configuration - window\.Offer18WebSDK.trackConversion()" %}

1. **domain** (Mandatory) : Postback domain of the user.
2. **accountId** (Mandatory) : Offer18 account id of the user.
3. **offerId** (Mandatory) : Id of the campaign.
4. **coupon :** Coupon code can be used here
5. **postbackType** : It can be either `'iframe'` or `'pixel'`, default value is `'iframe'`.&#x20;
6. **isGlobalPixel** : User can configure global pixel by setting this `true` , default value is `false`.
7. **iGamingCampaign :** User can configure iGaming Postback by setting this `true` , default value is `false`.&#x20;
8. **allowMultiConversion** : User can allow MultiConversion by setting this `true` , default value is `false`.&#x20;
9. **conversionData** : This object contains the parameters which can be used to get values from network.
10. **userActivityData** : This object contains the parameters which can be use to track iGaming user activity data
    {% endtab %}
    {% endtabs %}

{% hint style="info" %}
**User ID** (ig-user-id) is Mandatory to be passed in iGaming Postback
{% endhint %}

#### **Example code**

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

***

## Debug Mode

To enable debug mode in an SDK, one can add the following code inside your script:

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

Enabling debug mode allows user to get more detailed information about the working of the SDK, including any errors or debugging messages.
