dataunlocker/save-analytics-from-content-blockers

Can't add DataUnlocker script to Nextjs project

Closed this issue · 5 comments

I tried to add DataUnlocker script to Nextjs project.

So instead of adding the script to .html file as your tutorial, it should be added in _document.js of Nextjs project.

But I got a bunch of VSCode errors after added. Project also failed to start.

Screen Shot 2021-02-24 at 11 18 32 PM

I made an empty Nextjs project to add DataUnlocker script as an example: https://github.com/huongpanprices/dataunlocker-nextjs

It would be great to get your support. Thanks.

Hello! Thanks for filing the issue.

Please check vercel/next.js#1413 and let me know whether it helped.

Thanks!

@ZitRos I tried it but still couldn't resolve the issue

huongpanprices/dataunlocker-nextjs@b995474

Screen Shot 2021-02-24 at 11 39 04 PM

This happens because encoded script has ` symbol which needs to be escaped. I.e. you need to CTRL+R all the code and replace it with \`. You will also need to escape some other symbols and backslashes :)

It's better to use unencoded script in your case:

image

...or use Continuous Integration option in your CI pipeline which will properly modify the output HTML file made by NextJS.

Works well now. Thanks for your help. :D

You're welcome! Happy DataUnlocking! :)