clarity: A error about call clarity.
I use below in my website:(xxxxxxx is the proj id)
<script async="" src="https://www.clarity.ms/tag/xxxxxxx"></script>
But it show in F12:
Uncaught TypeError: Cannot read properties of undefined (reading 'v')
at xxxxxxxx:1:79
at xxxxxxxx:1:329
And after 24 hours, my clarity dashboard is empty.So what should i do?
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 16
@ClaritySupport , sorry for the delayed response. I got it to work with this snippet in my
_document.tsx
:Hope it helps others!
Thank you for the great service š
Iām running into the same issue on a Next.js app
I have been studying the problematic code. Here it is:
If we āevaluateā the variables, we would get to the following statement in line 2:
Which is supposed to break, given that
window.clarity
has not been defined at all. My surprise is not that this script fails, but that nobody else is reporting it. šI wanted to push a PR to improve it, but couldnāt find where this snippet is located.
Iām having the same error and iām using nuxt.config.js ( Nuxt @ v2.16.2 )
Probably, this error is caused by browserās behavior.
Define the two code snippets as follows.
is ClarityLoadingScript and
is ClarityExecutingScript.
Importantly, ClarityExecutingScript must be called after completed executing ClarityLoadingScript.
No problem if you write the following, because ClarityLoadingScript and ClarityExecutingScript will be executed synchronously.
But if you write the following, error maybe caused.
In this case,
async attribute
is present on ClarityLoadingScript and when ClarityExecutingScript is executed, window[āclarityā] maybe not be defined because it is not clear whether ClarityLoadingScript has completed execution or not. SoUncaught TypeError: Cannot read properties of undefined (reading 'v')
was caused.Make sure you are running ClarityExecutingScript after ClarityLoadingScript execution is complete.
@ClaritySupport Based on these, you should modify your GTM official template. Currently, Clarityās code snippets are inserted via GTM.
As explained above, when these two sources are read asynchronously, it is non-deterministic as to which completes first. So, you must to fix it to use the defer attribute instead of the async attribute.
Scripts with the defer attribute specified will be executed in the order they appear in the HTML document, but will not block the parsing of this.
Iām not developer for microsoft or clarity. Iām just a user of clarityā¦
Yeah, it seems that no developer works for it. I have given up using it.