Problem with live chat and GDPR cookie banner
- This topic has 6 replies, 2 voices, and was last updated 1 year, 2 months ago by .
-
AuthorPosts
-
April 4, 2021 at 8:59 pm #5534
Jampi
Hi everyone!
I’ve finished to move my website (https://www.visaworld.it) from wordpress to publlii using the simple blog theme, and I’m quite happy, same design but far better performance.
I’ve only 1 problem left to solve: I’ve set a live chat (crisp – https://crisp.chat/en/), added the script to the footer, set the gdpr type; the code is:
<script type="{{ gdprScriptBlocker "functions"}}">window.$crisp=[];window.CRISP_WEBSITE_ID="xxxxxxxx";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();</script>
Now, after you give the cookie consent, the chat appears and works as expected, but if you change page, it doesn’t show up again.
I tried moving moved the script, but the gdpr function stopped blocking the chat script.
In order to block the script i must place it under the publii footer:
{{{@footerCustomCode}}} {{{ publiiFooter }}} <script type="{{ gdprScriptBlocker "functions"}}" >window.$crisp=[];window.CRISP_WEBSITE_ID="xxxxxxx";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();</script> </body> </html>
Any sugestion? What am I doing wrong?
Thank you!
April 4, 2021 at 9:15 pm #5535Jampi
The code didn’t show:
<script type="{{ gdprScriptBlocker "functions"}}">window.$crisp=[];window.CRISP_WEBSITE_ID="xxxxxxxx";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();</script>
After you give the cookie consent, the chat appears and works as expected, but if you change page clicking on another link, in the new page the chat doesn’t show up again. It is not a problem of the page, beacuse if you open the same page in ingognito mode, the chat appears and works, but again, if you go to another page, no more chat.
I tried moving the script above the lasy loading if statement and it works properly in every page, but the problem is thata the GDPR function don’t block the script, which runs even without user consent.
To block the script I have to place the script just before the closure of the body tag, as follow:
{{{@footerCustomCode}}} {{{ publiiFooter }}} <script type="{{ gdprScriptBlocker "functions"}}" >window.$crisp=[];window.CRISP_WEBSITE_ID="xxxxxxx";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();</script> </body> </html>
Any suggestion? An help would be much apreciated.
Thank you!
April 5, 2021 at 1:06 pm #5538Jampi
Sorry guys, since the site is live, I prefered to switch back to my old cookie solution. However, if someone experienced the same problem and found a solution, please tell me, I’d like better to use a self-hosted solution.
April 5, 2021 at 6:28 pm #5543Tomasz Dziuda
Hi @Jampi,
Do you have the same issue with other scripts or the chat was the only one which have this issue?
I am asking, because the code on save and load does exactly the same things. Or maybe you have some localStorage issue in your browser or some adblock extension which causes the problem?
--
Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!April 5, 2021 at 8:21 pm #5545Jampi
Hi Tomasz,
I tried 2 different chat script, both had the same problem, honestly didn’t have other scripts to try, but I’ll do some experiment.
Thanks for the interest!
April 7, 2021 at 12:18 pm #5563Tomasz Dziuda
Hi again Jampi 🙂
I have found a reason of your issue 🙂
You MUST place your scripts which uses gdprScriptBlocker helper BEFORE
{{{ publiiFooter }}}
Because if it is placed after that fragment – our script does not detect scripts placed in that place 🙂
I have added a proper notice in the documentation: https://getpublii.com/dev/gdprscriptblocker-helper/#gdprscriptblocker-helper
--
Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!April 7, 2021 at 6:15 pm #5572Jampi
This reply has been marked as private. -
AuthorPosts
- You must be logged in to reply to this topic.