How to send the UTM parameter(s) along with the response data

If you need to store and send the UTM parameter(s) with the response data, you can use such a technique:

Step 1. Enable developer mode:

Step 2.* Set a handler for onInit widget event in the Bot settings -> Advanced initialization (learn more here), in order to preserve the parameter for the returning visitors:

{
    onInit: function() {
        var utmSource = new quriobot.URL(window.location.href, true).query.utm_source;
        if (utmSource) {
            quriobot.store.set('utmSource', utmSource)
        }
    }
}

This handler utilizes the quriobot.store utility to read the utm_source parameter from the URL and store it in the store if it’s passed.

Step 3. Create a script variable (learn more here) to read from the previously-stored utm_source parameter:

function(callback, variables) {
    // The `callback` argument has to be called with the result value in order to support the async operations. The `variables` argument is an object containing other variables
    callback(quriobot.store.get('utmSource') || '')
}

This variable utilizes the quriobot.store utility to read the previously stored utm_source parameter from the URL.

Step 4. Add a Goto step (learn more here) to store the previously created variable along with the response, this step is better to add as an entry point for your bot to ensure it’s always visited:

Step 5 (optional). If you need to use the parameter(s) in the Response Connections, you can use an additional step variable:

then you can use it like:

{{utmSourceStep}}

in the Bot Response Actions.

You’re done!

Now you can see the stored UTM parameter in the response data:

Edit this page