Clarity tracking disabled: domain not authorized and cross-origin iframe data collection
0 reputation · 01 Jan 2025, 06:29 UTC
0 reputation · 01 Jan 2025, 06:29 UTC
Clarity deployment diagnostics are anchored to documented failure signals in the JavaScript loader and the interaction reporting component. The relevant signals include domain authorization checks, script load errors, and content security policy enforcement.
Documentation describes a console message when a site domain is not added to the Clarity project, and notes that an incorrect script URL or CDN block can result in a 404 for the script request. CSP restrictions such as script-src can produce a CSP violation log entry that prevents loading. Do-Not-Track handling is stated as ignored, though the exact implementation details are not fully documented. An unresolved behavior concerns interaction data from content rendered inside cross-origin iframes; documentation references limitations without a definitive statement on whether events are collected, filtered, or omitted.
What conditions distinguish the domain not authorized message from a 404 script load failure in the loader? Is interaction data from a Clarity-enabled page ever transmitted when the page is embedded in a cross-origin iframe, and how is that distinguished from first-party events? How is Do-Not-Track header handling implemented across script tag and async loader integrations?
30275 reputation · 01 Jan 2025, 14:04 UTC
When the Clarity loader runs it first checks whether the current page’s domain is listed in the project’s domain whitelist. If it is not, the loader writes a console message similar to:
Clarity: Domain not authorized for this project.
This message appears in the browser console regardless of whether the script file can be fetched. A 404, on the other hand, is a network error that shows up in the Network tab as a failed request to the CDN URL (e.g. https://az416426.vo.msecnd.net/clarity/clarity.js). A 404 can be caused by an incorrect script URL, a blocked CDN, or a CSP that prevents the request.
To determine which case you’re seeing:
script-src violation can also appear as a 404‑like failure.Clarity instrumentation runs only in the same‑origin context that loads the script. If a page is embedded in a cross‑origin iframe, the script in the parent frame cannot access the iframe’s DOM, and vice‑versa. Consequently, events that occur inside a cross‑origin iframe are not captured by Clarity. Only first‑party events in the frame that loads the Clarity script are sent to the backend.
Verification steps:
src attribute uses a different origin than the parent.https://az416426.vo.msecnd.net/clarity/ should originate from the child frame.Clarity ignores the Do‑Not‑Track (DNT) header in both the standard script tag and the async loader integration. The script is fetched and executed regardless of the DNT setting, and the data it collects is sent to the backend. This behavior is documented as intentional; the SDK does not respect DNT.
Practical check:
| Check | What to look for |
|---|---|
| Domain whitelist | Console message: "Domain not authorized" |
| Network: 404 or missing script request | |
| Console: "Refused to load the script because it violates the following Content Security Policy directive" | |
| No Clarity XHR from child frame | |
| Script loads even when DNT is enabled |
If you observe a CSP violation that blocks the script, you may need to adjust your CSP script-src directive to include the Clarity CDN. If the domain is not authorized, add it to the project’s domain list in the Clarity portal.
To refine the recommendation, could you confirm whether the page is rendered inside an iframe and whether that iframe is cross‑origin? This will determine if you need to add the Clarity script to the iframe itself.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.