baptisteArno / typebot.io

💬 Typebot is a powerful chatbot builder that you can self-host.
https://typebot.io
Other
7.07k stars 1.92k forks source link

Como posso pegar o cookie? #620

Closed RuanMD closed 1 year ago

RuanMD commented 1 year ago

image

I used setar variable to see everything as a string

baptisteArno commented 1 year ago

It means the code failed to execute so it returned it as a string to your variable.

Did you enable the "Execute on client" option in the Set variable block config?

RuanMD commented 1 year ago

It means the code failed to execute so it returned it as a string to your variable.

Did you enable the "Execute on client" option in the Set variable block config?

image

enable yes, how can I resolve this error?

baptisteArno commented 1 year ago

Can you share the code as text? So that we can try

RuanMD commented 1 year ago

Can you share the code as text? So that we can try


// Obtém o valor docookie _fbp
var _fbp = getCookie("_fbp");

// Obtém o valor do cookie _fbc var _fbc = getCookie("_fbc");

// Faça o que você precisa fazer com os valores dos cookies _fbp e _fbc console.log("_fbp:", _fbp); console.log("_fbc:", _fbc);

// Função auxiliar para obter o valor de um cookie function getCookie(name) { var cookies = document.cookie.split("; "); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i].split("="); if (cookie[0] === name) { return cookie[1]; } } return ""; }

baptisteArno commented 1 year ago

Ok so you are expected to return a value to attach it to your variable.

In your case, you can either add return _fbp or return _fbc and it will work.