๐ก๏ธ Essential C# - Microsoft Clarity Consent Verification
+
+
+ Purpose: This page tests the Microsoft Clarity consent implementation to ensure compliance with GDPR and similar regulations.
+ Testing: The verification function from Microsoft's documentation is implemented below.
+
+
+
+
๐งช Test Actions
+
+
+
+
+
+
+
+
+
+
๐ Real-time Status
+
+
Consent Manager Status:Loading...
+
Clarity Status:Loading...
+
Region Requires Consent:Loading...
+
+
+
+
+
๐ Console Output
+
Initializing consent verification test...
+
+
+
+
๐ Expected Results
+
+ โ When consent is DENIED:
+ โข analytics_storage: "DENIED"
+ โข ad_storage: "DENIED"
+ โข Clarity should not set cookies
+
+
+
+ โ When consent is GRANTED:
+ โข analytics_storage: "GRANTED"
+ โข ad_storage: "GRANTED"
+ โข Clarity can set cookies and track normally
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/EssentialCSharp.Web/wwwroot/js/consent-manager.js b/EssentialCSharp.Web/wwwroot/js/consent-manager.js
index ceb16233..22d51b08 100644
--- a/EssentialCSharp.Web/wwwroot/js/consent-manager.js
+++ b/EssentialCSharp.Web/wwwroot/js/consent-manager.js
@@ -312,8 +312,8 @@ class ConsentManager {
if (window.clarity) {
try {
clarity('consentv2', {
- ad_Storage: this.consentState.ad_storage,
- analytics_Storage: this.consentState.analytics_storage
+ ad_storage: this.consentState.ad_storage,
+ analytics_storage: this.consentState.analytics_storage
});
} catch (error) {
console.warn('Failed to update Clarity consent:', error);
@@ -507,4 +507,50 @@ window.openConsentPreferences = function() {
if (window.consentManager) {
window.consentManager.openConsentPreferences();
}
+};
+
+// Global function for verifying consent implementation (testing/debugging)
+window.verifyClarityConsent = function() {
+ console.log('=== Microsoft Clarity Consent Verification ===');
+
+ if (typeof clarity === 'undefined') {
+ console.log('โ Clarity not loaded yet. Please wait and try again.');
+ return;
+ }
+
+ try {
+ clarity('metadata', (d, upgrade, consent) => {
+ console.log('โ Clarity metadata callback executed');
+ console.log('๐ Consent Status:', consent);
+
+ if (consent) {
+ const analyticsStatus = consent.analytics_storage || 'UNKNOWN';
+ const adStatus = consent.ad_storage || 'UNKNOWN';
+
+ console.log(`๐ Analytics Storage: ${analyticsStatus}`);
+ console.log(`๐ Ad Storage: ${adStatus}`);
+
+ if (analyticsStatus === 'DENIED' && adStatus === 'DENIED') {
+ console.log('โ Consent properly denied - Clarity should not set cookies');
+ } else if (analyticsStatus === 'GRANTED' || adStatus === 'GRANTED') {
+ console.log('โ Consent granted - Clarity can set cookies based on granted permissions');
+ } else {
+ console.log('โ ๏ธ Unexpected consent status detected');
+ }
+ } else {
+ console.log('โ No consent object returned');
+ }
+
+ // Also show current consent manager state for comparison
+ if (window.consentManager) {
+ console.log('๐ Current Consent Manager State:');
+ console.log(' - Analytics Consent:', window.consentManager.hasAnalyticsConsent());
+ console.log(' - Advertising Consent:', window.consentManager.hasAdvertisingConsent());
+ console.log(' - Requires Consent:', window.consentManager.requiresConsent);
+ console.log(' - Full State:', window.consentManager.consentState);
+ }
+ }, false, true, true);
+ } catch (error) {
+ console.log('โ Error running verification:', error);
+ }
};
\ No newline at end of file
From 5a466ded3bc1bf4f9c1a3cb95764086e32d4f4b2 Mon Sep 17 00:00:00 2001
From: Benjamin Michaelis
Date: Sat, 20 Sep 2025 21:11:30 -0700
Subject: [PATCH 3/4] Delete EssentialCSharp.Web/wwwroot/consent-test.html
---
EssentialCSharp.Web/wwwroot/consent-test.html | 275 ------------------
1 file changed, 275 deletions(-)
delete mode 100644 EssentialCSharp.Web/wwwroot/consent-test.html
diff --git a/EssentialCSharp.Web/wwwroot/consent-test.html b/EssentialCSharp.Web/wwwroot/consent-test.html
deleted file mode 100644
index 14991537..00000000
--- a/EssentialCSharp.Web/wwwroot/consent-test.html
+++ /dev/null
@@ -1,275 +0,0 @@
-
-
-
-
-
- Essential C# - Consent Verification Test
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
๐ก๏ธ Essential C# - Microsoft Clarity Consent Verification
-
-
- Purpose: This page tests the Microsoft Clarity consent implementation to ensure compliance with GDPR and similar regulations.
- Testing: The verification function from Microsoft's documentation is implemented below.
-
-
-
-
๐งช Test Actions
-
-
-
-
-
-
-
-
-
-
๐ Real-time Status
-
-
Consent Manager Status:Loading...
-
Clarity Status:Loading...
-
Region Requires Consent:Loading...
-
-
-
-
-
๐ Console Output
-
Initializing consent verification test...
-
-
-
-
๐ Expected Results
-
- โ When consent is DENIED:
- โข analytics_storage: "DENIED"
- โข ad_storage: "DENIED"
- โข Clarity should not set cookies
-
-
-
- โ When consent is GRANTED:
- โข analytics_storage: "GRANTED"
- โข ad_storage: "GRANTED"
- โข Clarity can set cookies and track normally
-
-
-
-
-
-
-
\ No newline at end of file
From dbe1456b5f9c241b014645cce49f741c18bbd7b6 Mon Sep 17 00:00:00 2001
From: Benjamin Michaelis
Date: Sat, 20 Sep 2025 21:12:13 -0700
Subject: [PATCH 4/4] Update EssentialCSharp.Web/wwwroot/js/consent-manager.js
---
.../wwwroot/js/consent-manager.js | 46 -------------------
1 file changed, 46 deletions(-)
diff --git a/EssentialCSharp.Web/wwwroot/js/consent-manager.js b/EssentialCSharp.Web/wwwroot/js/consent-manager.js
index 22d51b08..ae107df4 100644
--- a/EssentialCSharp.Web/wwwroot/js/consent-manager.js
+++ b/EssentialCSharp.Web/wwwroot/js/consent-manager.js
@@ -507,50 +507,4 @@ window.openConsentPreferences = function() {
if (window.consentManager) {
window.consentManager.openConsentPreferences();
}
-};
-
-// Global function for verifying consent implementation (testing/debugging)
-window.verifyClarityConsent = function() {
- console.log('=== Microsoft Clarity Consent Verification ===');
-
- if (typeof clarity === 'undefined') {
- console.log('โ Clarity not loaded yet. Please wait and try again.');
- return;
- }
-
- try {
- clarity('metadata', (d, upgrade, consent) => {
- console.log('โ Clarity metadata callback executed');
- console.log('๐ Consent Status:', consent);
-
- if (consent) {
- const analyticsStatus = consent.analytics_storage || 'UNKNOWN';
- const adStatus = consent.ad_storage || 'UNKNOWN';
-
- console.log(`๐ Analytics Storage: ${analyticsStatus}`);
- console.log(`๐ Ad Storage: ${adStatus}`);
-
- if (analyticsStatus === 'DENIED' && adStatus === 'DENIED') {
- console.log('โ Consent properly denied - Clarity should not set cookies');
- } else if (analyticsStatus === 'GRANTED' || adStatus === 'GRANTED') {
- console.log('โ Consent granted - Clarity can set cookies based on granted permissions');
- } else {
- console.log('โ ๏ธ Unexpected consent status detected');
- }
- } else {
- console.log('โ No consent object returned');
- }
-
- // Also show current consent manager state for comparison
- if (window.consentManager) {
- console.log('๐ Current Consent Manager State:');
- console.log(' - Analytics Consent:', window.consentManager.hasAnalyticsConsent());
- console.log(' - Advertising Consent:', window.consentManager.hasAdvertisingConsent());
- console.log(' - Requires Consent:', window.consentManager.requiresConsent);
- console.log(' - Full State:', window.consentManager.consentState);
- }
- }, false, true, true);
- } catch (error) {
- console.log('โ Error running verification:', error);
- }
};
\ No newline at end of file