> ## 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 add an EXIT POP-UP on GreatPages

To add an **Exit Pop-up** to a page on **GreatPages**, follow the tutorial below:

||| The Exit Pop-up only works on the **DESKTOP** version (computer)

1. Log in to your account and go to the page editor;

2. Using the icons bar located on the left side of your screen, click on the **"Add Button"** option;

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

3. Once the button element has been inserted into the page, click on **"Edit"**;

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

4. In the menu that opens, click on **"Add link"** and select the **"Open a box (Pop-up)"** option;

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

5. With the pop-up element inserted into the page, use the left side menu of the screen to edit and customize it however you want;

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

6. Next we will need to find the ID of this element in order to move on to the next step of creating the exit pop-up. To do this, click on the button again, go to "Edit" and, in the "Code" tab, click to copy the **CSS selector of the element**

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

7. After that, click on the **"gear icon"** in the top right corner of the screen;

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

8. Then click on **"Javascript & CSS"**;

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

9. Click to **"Add"** a new code;

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

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

```
<script>
  const botaoPopUp = $('#e_1074261_1_87957 .c');
  /* se você deseja que o botão apareça na página remova a linha abaixo */
  botaoPopUp.css({ 'visibility': 'hidden' });
  /* Pegando o movimento do mouse */
  $(document).on('mouseleave', function (e) {
    console.log('Saiu da tela');
    console.log('Tem popup aberto? ' + $('.gpc_modal-fundo').length);
    console.log('Tem cookie gpages_popup_leave? ' + document.cookie.indexOf('gpages_popup_leave'));
    /* Verificando se saiu da tela e não tem popup aberto */
    if (!$('.gpc_modal-fundo').length) {
      /* Gerando cookie */
      var data = (new Date), data_limite = (new Date);
     data_limite.setTime(data_limite.getTime() + (180 * 24 * 60 * 60 * 1000));
      document.cookie = "gpages_popup_leave=" + data.getFullYear() + '-' + (data.getMonth() + 1) + '-' + data.getDate() + 'T' + data.getHours() + ':' + data.getMinutes() + ':' + data.getSeconds() + "; Expires=" + data_limite.toGMTString() + "; Path=/;";
      /* Clicando no botão */
      $(botaoPopUp).trigger('click');
    }
  });
</script>
```

11. Take the ID of the pop-up element identified earlier and paste it exactly in the space of the code where it says -> '#e\_0000000'

||| Do not add any other characters or spaces. After that, click on "Add";

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

12. To find out whether the code is working correctly, click on **"Preview"** and move your mouse toward closing the page.

As soon as you make this movement, the pop-up will be triggered.

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

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