You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I didn't feel good about sending 100KB+ for a simple cookie consent solution so I wrote my own in vanilla JS. It's around 4kB compressed with brotli. The goal was to make something small and versatile _enough_ that I could drop it on my optimized sites for basic analytics that wouldn't break the rules.
5
7
8
+
6
9
- Stores consent in `localStorage`, exposes in `window.Consent` and through custom events fired on `document`
console.log('This embedded script will be inserted when analytics consent is granted')
38
+
</script>
39
+
40
+
<!-- biscuitman config, unless its a one-page site serve this from biscuitman-config.js -->
41
+
<script>
42
+
biscuitman={
43
+
msg: 'By clicking "Accept All", you agree to the use of cookies for improving browsing, providing personalized ads or content, and analyzing traffic.',
44
+
info: `Cookies categorized as "Essential" are stored in your browser to enable basic site functionalities.
45
+
Additionally, third-party cookies are utilized to analyze website usage, store preferences, and deliver relevant content and advertisements with your consent.
46
+
While you have the option to enable or disable some or all of these cookies, note that disabling certain ones may impact your browsing experience.`,
essentialMessage: 'Essential cookies are reuired for basic site functionality',
50
+
functionalTitle: 'Functional',
51
+
functionalMessage: 'Functional cookies allow us to perform specific tasks such as sharing website content on social media platforms, gathering feedback, and enabling other third-party features',
52
+
analyticsTitle: 'Analytics',
53
+
analyticsMessage: 'Analytical cookies allow us to understand visitor interactions with the website, offering insights into metrics like visitor count, bounce rate, and traffic source',
54
+
analyticsCookies: {
55
+
'_ga': 'This cookie, set by Google Analytics, computes visitor, session, and campaign data, tracking site usage for analytical reports. It stores information anonymously, assigning a randomly generated number to identify unique visitors',
56
+
'_ga_*': 'Google Analytics uses this cookie for storing page view count'
57
+
},
58
+
performanceTitle: 'Performance',
59
+
performanceMessage: 'Performance cookies allow us to understand critical website performance indicators, contributing to an enhanced user experience for visitors',
60
+
advertisementTitle: 'Advertisement',
61
+
advertisementMessage: 'Advertisement cookies serve to deliver tailored advertisements to visitors based on their previous page visits and to evaluate the efficacy of advertising campaigns',
62
+
uncategorizedTitle: 'Uncategorized',
63
+
uncategorizedMessage: 'Uncategorized cookies are those currently under analysis and have not yet been assigned to a specific category',
64
+
acceptNonEU: false
65
+
}
66
+
</script>
67
+
<!-- biscuitman must be after biscuitman config and data-consent scripts -->
<p>Biscuits, the beloved treats that accompany tea time, snack breaks, and dessert cravings. In this comprehensive guide, we delve into the world of biscuits, exploring their history, varieties, and cultural significance.</p>
64
144
65
145
<h2>History of Biscuits</h2>
@@ -83,65 +163,5 @@ <h3>Jaffa Cakes</h3>
83
163
<p>While technically not biscuits but often included in biscuit assortments, Jaffa Cakes are a beloved snack consisting of a sponge cake base topped with a layer of orange-flavored jelly and coated in chocolate. The combination of tangy orange and rich chocolate makes Jaffa Cakes a delightful treat for any occasion.</p>
console.log('This embedded script will be inserted when analytics consent is granted')
114
-
</script>
115
-
116
-
<!-- biscuitman config, unless its a one-page site serve this from biscuitman-config.js -->
117
-
<script>
118
-
biscuitman={
119
-
msg: 'By clicking "Accept All", you agree to the use of cookies for improving browsing, providing personalized ads or content, and analyzing traffic.',
120
-
info: `Cookies categorized as "Essential" are stored in your browser to enable basic site functionalities.
121
-
Additionally, third-party cookies are utilized to analyze website usage, store preferences, and deliver relevant content and advertisements with your consent.
122
-
While you have the option to enable or disable some or all of these cookies, note that disabling certain ones may impact your browsing experience.`,
essentialMessage: 'Essential cookies are reuired for basic site functionality',
126
-
functionalTitle: 'Functional',
127
-
functionalMessage: 'Functional cookies allow us to perform specific tasks such as sharing website content on social media platforms, gathering feedback, and enabling other third-party features',
128
-
analyticsTitle: 'Analytics',
129
-
analyticsMessage: 'Analytical cookies allow us to understand visitor interactions with the website, offering insights into metrics like visitor count, bounce rate, and traffic source',
130
-
analyticsCookies: {
131
-
'_ga': 'This cookie, set by Google Analytics, computes visitor, session, and campaign data, tracking site usage for analytical reports. It stores information anonymously, assigning a randomly generated number to identify unique visitors',
132
-
'_ga_*': 'Google Analytics uses this cookie for storing page view count'
133
-
},
134
-
performanceTitle: 'Performance',
135
-
performanceMessage: 'Performance cookies allow us to understand critical website performance indicators, contributing to an enhanced user experience for visitors',
136
-
advertisementTitle: 'Advertisement',
137
-
advertisementMessage: 'Advertisement cookies serve to deliver tailored advertisements to visitors based on their previous page visits and to evaluate the efficacy of advertising campaigns',
138
-
uncategorizedTitle: 'Uncategorized',
139
-
uncategorizedMessage: 'Uncategorized cookies are those currently under analysis and have not yet been assigned to a specific category',
140
-
acceptNonEU: true
141
-
}
142
-
</script>
143
-
<!-- biscuitman must be after biscuitman config and data-consent scripts -->
0 commit comments