diff --git a/apps/docs/docs/editor/blocks/logic/set-variable.md b/apps/docs/docs/editor/blocks/logic/set-variable.md index 6eae2da3a..d2b9f18b8 100644 --- a/apps/docs/docs/editor/blocks/logic/set-variable.md +++ b/apps/docs/docs/editor/blocks/logic/set-variable.md @@ -50,3 +50,20 @@ window.location.href It will not give you the parent URL if you embed the bot on your site. A more bulletproof option is to pass the URL as a hidden variable in the embed code options. You can find an example [here](/embed/html-javascript#additional-configuration). ::: + +## Extract a cookie + +This code allows you to extract the value of a cookie called "my_cookie": + +```js +const getCookie = (name) => { + const value = `; ${document.cookie}` + const parts = value.split(`; ${name}=`) + if (parts.length === 2) return parts.pop().split(';').shift() + return 'not found' +} + +return getCookie('my_cookie') +``` + +As you can see the code can also be multi-line. The Set variable block will get the value following the `return` statement.