# Automated Trigger

This feature allows multiple tracking actions to be managed through a single configuration. Based on predefined conditions such as matching website paths, hostnames, or referral sources, the SDK automatically triggers the appropriate functions.

With this approach, tracking behavior can be controlled and customized without repeated setup, making it easier to manage and scale tracking across different scenarios.&#x20;

### Get Started

To start automated 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 %}

***

### TrackClick&#x20;

To track clicks using the automated SDK script, add the following code to your website.

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

{% code overflow="wrap" %}

```html
<script>
	window.Offer18SDK.init({
		automatedTrigger: true,
		opeations: [{
			triggerFunction: "trackClick",
			triggerconditios: [
				{
					mode: "<condition-mode>", // contain or equal
					type: "<condition-type>", // path / hostname / referral
					value: "<condition-value>"
				}
			],
			triggerConfig: {
				trackingURL: "https://example.com?c/o=xxx&m=000&a=000",
				keymapping: ['<OFFER18-PARAMETER>:<YOUR-PARAMETER>', '<OFFER18-PARAMETER>:<YOUR-PARAMETER>', ...]
			}
		}]
	})
</script>
```

{% endcode %}

***

### TrackImpression

To track impressions using the automated SDK script, add the following code to your website.

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

{% code overflow="wrap" %}

```html
<script>
	window.Offer18SDK.init({
		automatedTrigger: true,
		opeations: [{
			triggerFunction: "trackImpression",
			triggerconditios: [
				{
					mode: "<condition-mode>", // contain or equal
					type: "<condition-type>", // path / hostname / referral
					value: "<condition-value>"
				}
			],
			triggerConfig: {
				impressionURL: "https://example.com?i/o=xxx&m=000&a=000",
				keymapping: ['<OFFER18-PARAMETER>:<YOUR-PARAMETER>', '<OFFER18-PARAMETER>:<YOUR-PARAMETER>', ...]
			}
		}]
	})
</script>
```

{% endcode %}

***

### TrackConversion

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.init({
		automatedTrigger: true,
		operations: [
			{
				triggerFunction: "initializeUrlParam",
				triggerConditions: [
					{
						mode: "<condition-mode>", // contain or equal
						type: "<condition-type>", // path / hostname / referral
						value: "<condition-value>"
					}
				],
				triggerConfig: {
					clickIdParameter: "<YOUR-CLICK-ID-PARAMETER>",
				}
			}
		]
	})
</script>
```

After that add the following code in thankyou/order-confirmation page to your website.

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

```html
<script>
	window.Offer18WebSDK.init({
		automatedTrigger: true,
		operations: [
			{
				triggerFunction: "trackConversion",
				triggerConditions: [
					{
						mode: "<condition-mode>", // contain or equal
						type: "<condition-type>", // path / hostname / referral
						value: "<condition-value>"
					}
				],
				triggerConfig: {
					domain: '',
					accountId: '',
					offerId: '',
					coupon: '',
					postbackType: '', // 'iframe' or 'pixel'
					isGlobalPixel: false, // 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: '',
					}
				}
			}
		]
	});
</script>
```

### Debug Mode <a href="#debug-mode" id="debug-mode"></a>

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.

### Example Code

```html
<script src="https://web-resources.offer18.net/sdk/web/WebSDK.js"></script>
<script>
    window.Offer18SDK.init({
        automatedTrigger: true,
        opeations: [{
            triggerFunction: "trackClick",
            triggerconditios: [
                { mode: "equal", type: "hostname", value: "websiteurl.com" }
            ],
            triggerConfig: {
                trackingURL: "https://example.o18.click/c?o=0000000&m=0000",
                keymapping: ['a:utm_source']
            }
        },
        {
            triggerFunction: "trackImpression",
            triggerconditios: [
                { mode: "equal", type: "hostname", value: "websiteurl.com" }
            ],
            triggerConfig: {
                impressionURL: "https://example.o18.click/i?o=0000000&m=0000",
                keymapping: ['a:utm_source']
            }
        },
        {
            triggerFunction: "initializeUrlParam",
            triggerconditios: [
                { mode: "equal", type: "hostname", value: "websiteurl.com" }
            ],
            triggerConfig: {
                clickIdParameter: "tid",
            }
        },
        {
            triggerFunction: "trackConversion",
            triggerConditions: [
                { mode: "equal", type: "hostname", value: "websiteurl.com" },
                { mode: "contain", type: "path", value: "thank-you" }
            ],
            triggerConfig: {
                domain: 'example.o18.link',
                accountId: '0000',
                offerId: '00000000',
            }
        }
        ]
    });
</script>
```
