This commit is contained in:
2025-05-13 12:47:08 -03:00
parent 0f7b39c3cb
commit 34c23d9011
2 changed files with 19 additions and 3 deletions

View File

@@ -1,5 +1,11 @@
import type { CookieConsentConfig } from "vanilla-cookieconsent"; import type { CookieConsentConfig } from "vanilla-cookieconsent";
declare global {
interface Window {
dataLayer: Record<string, any>[];
gtag: (...args: any[]) => void;
}
}
export const config: CookieConsentConfig = { export const config: CookieConsentConfig = {
guiOptions: { guiOptions: {
consentModal: { consentModal: {
@@ -28,14 +34,18 @@ export const config: CookieConsentConfig = {
'<a href="https://marketingplatform.google.com/about/analytics/terms/br/" target="_blank">Google Analytics 4</a>', '<a href="https://marketingplatform.google.com/about/analytics/terms/br/" target="_blank">Google Analytics 4</a>',
onAccept: () => { onAccept: () => {
console.log("ga4 accepted"); console.log("ga4 accepted");
/*
window.gtag("consent", "update", { window.dataLayer = window.dataLayer || [];
function gtag(...args: any[]) {
window.dataLayer.push(args);
}
gtag("consent", "update", {
ad_storage: "granted", ad_storage: "granted",
ad_user_data: "granted", ad_user_data: "granted",
ad_personalization: "granted", ad_personalization: "granted",
analytics_storage: "granted", analytics_storage: "granted",
}); });
*/
}, },
onReject: () => { onReject: () => {
console.log("ga4 rejected"); console.log("ga4 rejected");

View File

@@ -32,6 +32,12 @@ interface Props extends HeadProps {}
dataLayer.push(arguments); dataLayer.push(arguments);
} }
gtag("js", new Date()); gtag("js", new Date());
gtag("consent", "default", {
ad_storage: "denied",
ad_user_data: "denied",
ad_personalization: "denied",
analytics_storage: "denied",
});
gtag("config", "GTM-N3F7P9ZB"); gtag("config", "GTM-N3F7P9ZB");
</script> </script>