> For the complete documentation index, see [llms.txt](https://docs.barte.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.barte.com/api-reference/3ds/coletar-dados-do-navegador.md).

# Coletar dados do Navegador

#### <i class="fa-triangle-exclamation">:triangle-exclamation:</i> **Campos importantes:**

Esses campos utilizados no script são obtidos na criação da sessão 3DS.

* `collectUrl`: URL onde o navegador vai enviar dados de background. Ela só aceita `POST` de formulário com o `token` no campo `JWT`, como no script abaixo; abrir a URL com `GET` (link, redirect ou `fetch` sem formulário) devolve `405` e a coleta não acontece.
* `token`: JWT usado no script de coleta.
* `id`: (setupId) — será enviado depois no pagamento.

#### **Objetivo:**

Antes de criar uma cobrança, é necessário coletar os dados do cliente. Para isso, é necessário incluir um script no front-end que fará essa coleta e enviará para o provedor 3DS. Existem 2 campos necessários para a coleta de dados, o **collectUrl** e o **token**. Esses campos são retornados na criação da sessão.

#### **Script de coleta:**

```html
<div style="display: none;">
  <iframe id="cardinal_collection_iframe" name="collectionIframe" height="1" width="1"></iframe>
  <form id="cardinal_collection_form" method="POST" target="collectionIframe">
    <input id="cardinal_collection_form_input" type="text" name="JWT" value="">
  </form>
</div>
<script>
  const collectUrl = '<collectUrl>';
  const token = '<token>';
  const docFormCardinal = document.getElementById('cardinal_collection_form');
  const docInputCardinal = document.getElementById('cardinal_collection_form_input');
  docFormCardinal.action = collectUrl;
  docInputCardinal.value = token;
  docFormCardinal.submit();
  window.addEventListener("message", function (event) {
    const origin = new URL(collectUrl).origin;
    if (event.origin === origin) {
      const data = JSON.parse(event.data);
      console.log('COLETA FINALIZADA:', data);
    }
  });
</script>

```

#### <i class="fa-triangle-exclamation">:triangle-exclamation:</i> **Observação:**

* O Seller precisa aguardar a finalização da coleta antes de prosseguir para a criação da cobrança.
* Coleta rápida (\~1s).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.barte.com/api-reference/3ds/coletar-dados-do-navegador.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
