Articles on: EU GDPR Cookies Notification

How to integrate Google Consent Mode V2 on Wix

Open Settings → Custom Code


Click to Custom code on Head section


Paste the code below to “Code snippet”, name it like “Consentik Code”

Select “Load code on each new page”

Apply
Code here:

<script id="cst-consent-mode">
function otValidateDefault(t){const e=t[0]??!1,o=t[1]??!1;if(e&&"consent"==e&&o&&"default"==o){const e=t[2]??{};if(Object.values(e).length){const t=Object.keys(e),o=Object.values(e).some((t=>"granted"==t)),a=t.includes("cst_default");return!o||o&&a}return!0}return!0}function gtag(){dataLayer.push(arguments)}window.otkConsent={ad_user_data:!0,ad_personalization:!0,ad_storage:!0,analytics_storage:!0,functionality_storage:!0,personalization_storage:!0,security_storage:!0,url_passthrough:!0,ads_data_redaction:!0},window.dataLayer=[],window.dataLayer.push=function(...t){t.forEach((t=>{if(otValidateDefault(t)){const e=t[0]??!1,o=t[1]??!1,a=t[2]??[];if(e&&"consent"==e&&o&&"default"==o&&a&&Object.keys(a).includes("cst_default")){const{cst_default:e,...o}=a;t[2]={...o},Array.prototype.push.call(this,t)}else Array.prototype.push.call(this,t)}else console.log("gr d",t)}))},window.OMG_CONSENT_EXTENSION_ENABLED=!1;const otConsentObserver=new MutationObserver((function(t){for(const e of t)if("childList"===e.type){const t=Array.from(e.addedNodes).filter((t=>"SCRIPT"===t.tagName&&1===t.nodeType));for(const e of t){const t=e.getAttribute("src");if(t&&t.includes("consentik.js"))return window.OMG_CONSENT_EXTENSION_ENABLED=!0,void otConsentObserver.disconnect()}}}));otConsentObserver.observe(document.documentElement,{childList:!0,subtree:!0}),window.dataLayer=window.dataLayer||[],function(t,e){t.otCookiesGCM={},t.otCookiesGCM={url_passthrough:!1,ads_data_redaction:!1,config:{ad_user_data:"denied",ad_personalization:"denied",ad_storage:"denied",analytics_storage:"denied",functionality_storage:"denied",personalization_storage:"denied",security_storage:"denied",wait_for_update:500}},gtag("consent","default",t.otCookiesGCM.config),addEventListener("DOMContentLoaded",(function(){const e=t.otkConsent;let o=function(t,e){return e.localStorage.getItem(t)}("_consentik_cookie",t),a=!0;if(o){o=JSON.parse(o);const n=o.consent;a=!n.includes("advertising"),console.log({acceptedCat:n}),t.otCookiesGCM.config={ad_user_data:e.ad_user_data&&n.includes("advertising")?"granted":"denied",ad_personalization:e.ad_personalization&&n.includes("advertising")?"granted":"denied",ad_storage:e.ad_storage&&n.includes("advertising")?"granted":"denied",analytics_storage:e.analytics_storage&&n.includes("analytics")?"granted":"denied",functionality_storage:e.functionality_storage&&n.includes("functional")?"granted":"denied",personalization_storage:e.personalization_storage&&n.includes("functional")?"granted":"denied",security_storage:e.security_storage&&n.includes("functional")?"granted":"denied"},console.log(" window.otCookiesGCM.config",t.otCookiesGCM.config),gtag("consent","update",{...t.otCookiesGCM.config})}t.otCookiesGCM.ads_data_redaction=t.otkConsent.ads_data_redaction&&a,t.otCookiesGCM.url_passthrough=t.otkConsent.url_passthrough,t.otCookiesGCM.ads_data_redaction&&gtag("set","ads_data_redaction",t.otCookiesGCM.ads_data_redaction),t.otCookiesGCM.url_passthrough&&gtag("set","url_passthrough",t.otCookiesGCM.url_passthrough)}))}(window,document);
</script>


Please make sure that our code is above like the image below:

Updated on: 26/11/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!