> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://ajuda.greatsoftwares.com.br/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to INSTALL UTMs in GreatPages

To **install UTMs on your page**, you will need to follow the tutorial below:

||| You cannot integrate your form with another platform until you have added the UTM code and created the hidden fields in the form.

1. Access the page editor and click on the **gear icon** in the top right corner;

![](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/click-ingre_ppdwtk.png)

2. Next, click on **"Javascript & CSS"**;

![](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/image_rwrjh0.png)

3. Click to **"Adicionar"** a new code;

![](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/image_gz9t6q.png)

4. Choose a name for your code, select the **"**Operation**"** option and add all of the code below into the text field;

```
<script>
    function URLToArray(url) {
        var request = {};
        if (url.indexOf('?') !== -1) {
            url = encodeURI(url);
            var pairs = url.substring(url.indexOf('?') + 1).split('&');
            for (var i = 0; i < pairs.length; i++) {
                if (!pairs[i]) continue;
                var pair = pairs[i].split('=');
                if (pair[1] == undefined || pair[1] == '') { request[decodeURIComponent(pair[0])] = ''; }
                else {
                    try { request[decodeURIComponent(pair[0])] = decodeURIComponent(unescape(pair[1])); }
                    catch (e) { request[decodeURIComponent(pair[0])] = pair[1]; }
                }
            }
        }
        return request;
    }
    /* Campos para integração */
    function CamposUTM(modal) {
        if (modal == undefined) { modal = false; }
        /* Formulários */
        let formularios = Array.from(document.querySelectorAll((modal ? '.gpc_modal ' : '') + 'form'));
        utm = URLToArray(window.location.href);
        let link_usar = '';
        if (Object.entries(utm).length) {
            for (var [key, value] of Object.entries(utm)) { link_usar += key + '=' + value + '&'; }
            if (link_usar.length) { link_usar = link_usar.substr(0, (link_usar.length - 1)); }
        }
        formularios.map(formulario => {
            /* Controle de get utm_source */
            $(formulario).find('.gpc_campo').each(function (i, campo) {
                let valor = $(campo).val();
                if (valor.indexOf('{') != -1 && valor.indexOf('}') != -1) {
                    let valor_limpo = valor.replace('{', '').replace('}', '');
                    utm.hasOwnProperty(valor_limpo) ? $(campo).val(utm[valor_limpo]) : $(campo).val('');
                }
            });
            let botao = $(formulario).find('.gpc_botao');
            if (botao.attr('gpc-link') !== undefined && botao.attr('gpc-link') !== '') {
                try {
                    let link_new = new URL(botao.attr('gpc-link'));
                    for (var [key, value] of Object.entries(utm)) { link_new.searchParams.set(key, value); }
                    botao.attr('gpc-link', `${link_new.toString()}`);
                } catch (error) {
                    let concatenar = '?';
                    if (botao.attr('gpc-link').indexOf('?') !== -1) { concatenar = '&'; }
                    botao.attr('gpc-link', botao.attr('gpc-link') + concatenar + link_usar);
                }
            }
        });
        /* Botões */
        if (link_usar != '') {
            /* Habilitar para boões expecificos */
            let botoes = Array.from(document.querySelectorAll((modal ? '.gpc_modal ' : '') + '.link_externo'));
            botoes.map(link => {
                /* Controle de get utm_source */
                $(link).each(function (i, href) {
                    if ($(href).attr('href') !== undefined && $(href).attr('href') !== '') {
                        try {
                            let link_new = new URL($(href).attr('href'));
                            for (var [key, value] of Object.entries(utm)) { link_new.searchParams.set(key, value); }
                            $(href).attr('href', `${link_new.toString()}`);
                        } catch (error) {
                            let concatenar = '?';
                            if ($(href).attr('href').indexOf('?') !== -1) { concatenar = '&'; }
                            $(href).attr('href', $(href).attr('href') + concatenar + link_usar);
                        }
                    }
                });
            });
        }
    }
    CamposUTM();
    $('body').on('click', '.link_popup', function () { setTimeout(() => { CamposUTM(true); }, 200); });
</script>
```

![](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/image_8swk6b.png)

Now, you need to create the fields in the form so that it captures the conversion information.

5. Click on the form and then click on **"Edit"**;

![](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/image_1ttnh7w.png)

6. In the Configurações tab (on the right side of the screen), click on **"add** field **"**;

![](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/image_j9unkv.png)

7. Select **"**Hidden field**"** as the field type, and add the UTM field you want to receive;

![](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/image_17hnmnw.png)

8. Enter the **"**Field title**"**;

![](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/image_1xal3gs.png)

9. And between **"{}"** (curly braces) enter the UTM value. (For example, if you want the field to receive the value coming from "utm source", the hidden field value must be **"{utm\_source}"**;

![](https://storage.crisp.chat/users/helpdesk/website/-/a/6/a/b/a6ab90d8350d6000/image_1zx92.png)

Finally, save the added fields!

Still have questions? Reach out to our team on Chat! We're always happy to help. :-)  