# Disparador automatizado

Esta función permite gestionar múltiples acciones de seguimiento mediante una única configuración. Basado en condiciones predefinidas como la coincidencia de rutas del sitio web, nombres de host o fuentes de referencia, el SDK desencadena automáticamente las funciones apropiadas.

Con este enfoque, el comportamiento de seguimiento se puede controlar y personalizar sin configuraciones repetidas, lo que facilita gestionar y escalar el seguimiento en diferentes escenarios.&#x20;

### Comenzar

Para comenzar el seguimiento automatizado con el SDK web de Offer18, es necesario agregar una etiqueta script en el sitio web.

<mark style="color:morado;">Ubicación: Encabezado (Todas las páginas)</mark>

{% code fullWidth="false" %}

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

{% endcode %}

***

### RastrearClic&#x20;

Para rastrear clics usando el script automatizado del SDK, agregue el siguiente código a su sitio web.

<mark style="color:morado;">Ubicación: Encabezado (Todas las páginas)</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 %}

***

### RastrearImpresión

Para rastrear impresiones usando el script automatizado del SDK, agregue el siguiente código a su sitio web.

<mark style="color:morado;">Ubicación: Encabezado (Todas las páginas)</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 %}

***

### RastrearConversión

Los usuarios deben agregar el siguiente fragmento de código en todas las páginas de destino excepto la página de confirmación de pedido / página de éxito del pedido (Gracias).

<mark style="color:morado;">Ubicación: Encabezado (Todas las páginas)</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>
```

Después de eso, agregue el siguiente código en la página de agradecimiento/confirmación de pedido a su sitio web.

<mark style="color:morado;">Ubicación: Página de agradecimiento/Página de éxito del pedido (Una página)</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>
```

### Modo de depuración <a href="#debug-mode" id="debug-mode"></a>

Para habilitar el modo de depuración en un SDK, se puede agregar el siguiente código dentro de su script:

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

Habilitar el modo de depuración permite al usuario obtener información más detallada sobre el funcionamiento del SDK, incluidos errores o mensajes de depuración.

### Código de ejemplo

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


---

# 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/es/red/sdk/disparador-automatizado.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.
