Skip to content

Commit 0e3fabf

Browse files
Implement comprehensive cookie consent management for Microsoft Clarity and Google Analytics
Co-authored-by: BenjaminMichaelis <[email protected]>
1 parent fc4dab5 commit 0e3fabf

File tree

3 files changed

+573
-3
lines changed

3 files changed

+573
-3
lines changed

EssentialCSharp.Web/Views/Home/Privacy.cshtml

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,93 @@
33
}
44
<h1>@ViewData["Title"]</h1>
55

6-
<p>Use this page to detail your site's privacy policy.</p>
6+
<div class="container">
7+
<div class="row">
8+
<div class="col-lg-8">
9+
<h2>Privacy Policy</h2>
10+
<p>At Essential C#, we are committed to protecting your privacy and ensuring you have a positive experience on our website.</p>
11+
12+
<h3>Information We Collect</h3>
13+
<p>We collect information to provide better services to our users. The types of information we collect include:</p>
14+
<ul>
15+
<li><strong>Usage Information:</strong> How you interact with our website, including pages visited, time spent, and navigation patterns</li>
16+
<li><strong>Technical Information:</strong> Browser type, operating system, IP address, and device information</li>
17+
<li><strong>Account Information:</strong> When you create an account, we collect your email address and any profile information you provide</li>
18+
</ul>
19+
20+
<h3>How We Use Your Information</h3>
21+
<p>We use the information we collect to:</p>
22+
<ul>
23+
<li>Provide and improve our services</li>
24+
<li>Analyze website usage to enhance user experience</li>
25+
<li>Communicate with you about updates and features</li>
26+
<li>Ensure website security and prevent fraud</li>
27+
</ul>
28+
29+
<h3>Cookies and Tracking Technologies</h3>
30+
<p>We use cookies and similar technologies to enhance your browsing experience. Our website uses:</p>
31+
<ul>
32+
<li><strong>Essential Cookies:</strong> Required for basic website functionality</li>
33+
<li><strong>Analytics Cookies:</strong> Help us understand how you use our site (Google Analytics, Microsoft Clarity)</li>
34+
<li><strong>Advertising Cookies:</strong> Used to deliver relevant advertisements</li>
35+
</ul>
36+
37+
<p>You can manage your cookie preferences at any time by clicking the "Cookie Preferences" link in our footer.</p>
38+
39+
<div class="mt-3 mb-3">
40+
<button class="btn btn-primary" onclick="openConsentPreferences()">
41+
<i class="fa fa-cog me-2"></i>Manage Cookie Preferences
42+
</button>
43+
</div>
44+
45+
<h3>Your Rights</h3>
46+
<p>Depending on your location, you may have certain rights regarding your personal information:</p>
47+
<ul>
48+
<li>Access to your personal information</li>
49+
<li>Correction of inaccurate information</li>
50+
<li>Deletion of your personal information</li>
51+
<li>Restriction of processing</li>
52+
<li>Data portability</li>
53+
<li>Objection to processing</li>
54+
</ul>
55+
56+
<h3>Third-Party Services</h3>
57+
<p>Our website uses the following third-party services that may collect information:</p>
58+
<ul>
59+
<li><strong>Google Analytics:</strong> Web analytics service provided by Google Inc.</li>
60+
<li><strong>Microsoft Clarity:</strong> User behavior analytics service provided by Microsoft Corporation</li>
61+
</ul>
62+
63+
<h3>Data Retention</h3>
64+
<p>We retain your information only as long as necessary to provide our services and fulfill the purposes outlined in this privacy policy.</p>
65+
66+
<h3>International Transfers</h3>
67+
<p>Your information may be transferred to and processed in countries other than your own. We ensure appropriate safeguards are in place for such transfers.</p>
68+
69+
<h3>Contact Us</h3>
70+
<p>If you have questions about this privacy policy or your personal information, please contact us through our GitHub repository or at the contact information provided on <a href="https://intellitect.com/about/privacy-policy/" target="_blank">IntelliTect's Privacy Policy</a>.</p>
71+
72+
<h3>Changes to This Policy</h3>
73+
<p>We may update this privacy policy from time to time. We will notify you of any material changes by posting the new policy on this page.</p>
74+
75+
<p><small><em>Last updated: @DateTime.Now.ToString("MMMM dd, yyyy")</em></small></p>
76+
</div>
77+
<div class="col-lg-4">
78+
<div class="card">
79+
<div class="card-header">
80+
<h5>Quick Actions</h5>
81+
</div>
82+
<div class="card-body">
83+
<div class="d-grid gap-2">
84+
<button class="btn btn-outline-primary" onclick="openConsentPreferences()">
85+
<i class="fa fa-cog me-2"></i>Cookie Preferences
86+
</button>
87+
<a href="https://intellitect.com/about/privacy-policy/" target="_blank" class="btn btn-outline-secondary">
88+
<i class="fa fa-external-link me-2"></i>IntelliTect Privacy Policy
89+
</a>
90+
</div>
91+
</div>
92+
</div>
93+
</div>
94+
</div>
95+
</div>

EssentialCSharp.Web/Views/Shared/_Layout.cshtml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,43 @@
7878
<environment exclude="Development">
7979
<script type="importmap" asp-importmap="@prodMap"></script>
8080
</environment>
81+
<!-- Cookie Consent Manager - Load before analytics -->
82+
<script src="~/js/consent-manager.js" asp-append-version="true"></script>
83+
84+
<!-- Microsoft Clarity - Will be activated based on consent -->
8185
<script type="text/javascript">
8286
(function (c, l, a, r, i, t, y) {
8387
c[a] = c[a] || function () { (c[a].q = c[a].q || []).push(arguments) };
8488
t = l.createElement(r); t.async = 1; t.src = "https://www.clarity.ms/tag/" + i;
8589
y = l.getElementsByTagName(r)[0]; y.parentNode.insertBefore(t, y);
8690
})(window, document, "clarity", "script", "g4keetzd2o");
8791
</script>
92+
8893
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css">
8994
<!-- Markdown and sanitization libraries -->
9095
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
9196
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/purify.min.js"></script>
92-
<!-- Google tag (gtag.js) -->
97+
98+
<!-- Google tag (gtag.js) - Will be activated based on consent -->
9399
<script async src="https://www.googletagmanager.com/gtag/js?id=G-761B4BMK2R"></script>
94100
<script>
95101
window.dataLayer = window.dataLayer || [];
96102
function gtag() { dataLayer.push(arguments); }
103+
104+
// Initialize gtag but don't configure until consent is given
97105
gtag('js', new Date());
98-
gtag('config', 'G-761B4BMK2R');
106+
107+
// Configuration will be handled by consent manager
108+
// Only configure if consent is already granted or region doesn't require consent
109+
document.addEventListener('DOMContentLoaded', function() {
110+
// Small delay to ensure consent manager is initialized
111+
setTimeout(function() {
112+
if (window.consentManager &&
113+
(window.consentManager.hasAnalyticsConsent() || !window.consentManager.requiresConsent)) {
114+
gtag('config', 'G-761B4BMK2R');
115+
}
116+
}, 100);
117+
});
99118
</script>
100119
<style>
101120
[v-cloak] {
@@ -506,6 +525,9 @@
506525
<div class="col-12 col-md-auto align-self-end p-2">
507526
<a target="_blank" rel="noreferrer noopener" href="https://intellitect.com/about/privacy-policy/">Privacy</a>
508527
</div>
528+
<div class="col-12 col-md-auto align-self-end p-2">
529+
<a href="javascript:void(0)" onclick="openConsentPreferences()">Cookie Preferences</a>
530+
</div>
509531
<div class="col-12 col-md-auto align-self-end p-2"><a asp-route="TermsOfService">Terms Of Service</a></div>
510532
</div>
511533
</footer>

0 commit comments

Comments
 (0)