If you plan to use any of the following analytics tools, please refer to the codes provided in the document for proper setup.
TABLE OF CONTENTS
Facebook pixel
<script> !function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window, document,'script', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('consent', 'revoke'); fbq('init', '{your-pixel-id-goes-here}'); fbq('track', 'PageView'); window.addEventListener('LCCookieConsentDoneFB',function(cookieConsent){ fbq('consent', cookieConsent.detail.fb)},!1) </script>
Google Analytics
<script> window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag("consent", "default", { ad_storage: "denied", ad_user_data: "denied", ad_personalization: "denied", analytics_storage: "denied", }); window.addEventListener( "LCCookieConsentDoneGTag", function (cookieConsent) { if (cookieConsent.detail.gtag === 'grant'){ gtag("consent", "update", { ad_storage: "granted", ad_user_data: "granted", ad_personalization: "granted", analytics_storage: "granted", }); } }, !1 ); </script> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script> <script> gtag("js", new Date()); gtag("config", "TAG_ID"); </script>
Google Tag Manager
<!-- Google Tag Manager --> <script> window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag("consent", "default", { ad_storage: "denied", ad_user_data: "denied", ad_personalization: "denied", analytics_storage: "denied", }); window.addEventListener( "LCCookieConsentDoneGTM", function (cookieConsent) { if (cookieConsent.detail.gtm === 'grant'){ gtag("consent", "update", { ad_storage: "granted", ad_user_data: "granted", ad_personalization: "granted", analytics_storage: "granted", }); } }, !1 ); </script> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-XXXXXX');</script> <!-- End Google Tag Manager -->
Reading Cookie Categories
The below code is optional if you wish to read consent or categories user has accepted for other custom code or third party javascript
// Helper function to get consented categories function getConsentedCategories() { const categoriesCookie = document.cookie .split('; ') .find(row => row.startsWith('cookie-categories=')); if (categoriesCookie) { // Convert cookie value to array return categoriesCookie.split('=')[1].split(','); } return []; } // Helper function to check if category is allowed function isCategoryAllowed(category) { const categories = getConsentedCategories(); return categories.includes(category); } // Helper function to get cookie config function getCookieConfig() { const cookieConfig = document.cookie .split('; ') .find(row => row.startsWith('cookie-config=')); if (cookieConfig) { return cookieConfig.split('=')[1]; // Returns: all, essential, or custom } return undefined; // Return undefined if user hasn't made a choice yet }
Important Notes:
The cookie categories are stored in the cookie-categories cookie
Categories are comma-separated (e.g., "essential,advertising,analytics")
Always check for initial consent when loading your marketing tools
Listen for consent change events to update tool settings
Remove any <noscript> tags as they may bypass consent checks