Open vaulstein opened 2 years ago
I ran into the same problem and came across https://stackoverflow.com/questions/72210974/microsoft-clarity-not-working-with-next-js-react-js-project.
The cause is very simple, but a trap.
id="clarity"
breaks the library. Try to change it into id="ms_clarity"
or whatever.
I am trying to add clarity to a Next JS project. I have followed some online resources which have shown that scripts for Google tag manager/Clarity can be added in the below way.
File: app.tsx
This code triggers successfully and is fetching another script file and trying to inject it, which throws error while execution. Below is the script which is called by Clarity and throws an error:
Successful 1st call Error thrown is as below:
Have debugged a is window and c is a string "clarity".
The code works fine in a React project but is not working in Next JS.