Skip to content

Commit 5055f4f

Browse files
committed
fix: allow GTM usage without user cookie consent #465
1 parent 1fb6af7 commit 5055f4f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

plugins/tracking.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ export default defineNuxtPlugin((nuxtApp) => {
1111
provide: {
1212
trackingInit: (config: VidoConfig): void => {
1313
if (navigator.doNotTrack !== '1') {
14-
const consentIsGranted = localStorage.getItem('vue-cookie-accept-decline-cookies-consent') === 'accept'
15-
const googleTagManagerId = config.GOOGLE_TAG_MANAGER_ID
14+
const { GOOGLE_TAG_MANAGER_ID, COOKIES_CONSENT } = config
15+
16+
if (GOOGLE_TAG_MANAGER_ID) {
17+
const consentIsGranted = COOKIES_CONSENT
18+
? localStorage.getItem('vue-cookie-accept-decline-cookies-consent') === 'accept'
19+
: true // Bypass consent if COOKIES_CONSENT is not enabled
1620

17-
if (googleTagManagerId) {
1821
trackers.push(
1922
new Google(
2023
nuxtApp.vueApp,
2124
!consentIsGranted,
22-
googleTagManagerId,
25+
GOOGLE_TAG_MANAGER_ID,
2326
),
2427
)
2528
}

0 commit comments

Comments
 (0)