Site Tags

Titre

OldNew
11Site Tags

Lien permanent

OldNew
11site_tags

Contenu

OldNew
11# Site Tags
2
3## Examples
4
5### Google Site Tags
6
7```html
8<script>
9 try {
10 (() => {
11 if (typeof hasPrivacyConsent !== 'undefined' && hasPrivacyConsent('functionality')) {
12
13 let google_site_tags_id = 'GTM-XXXXXX';
14
15 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
16 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
17 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
18 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
19 })(window,document,'script','dataLayer',google_site_tags_id);
20
21 gtag('consent', 'default', {
22 'functionality_storage': 'denied',
23 'personalization_storage': 'denied',
24 'security_storage': 'denied',
25 'analytics_storage': 'denied',
26 'ad_storage': 'denied',
27 'ad_user_data': 'denied',
28 'ad_personalization': 'denied'
29 });
30
31 gtag('consent', 'update', {
32 'functionality_storage': hasPrivacyConsent('functionality') ? 'granted' : 'denied',
33 'personalization_storage': hasPrivacyConsent('personalization') ? 'granted' : 'denied',
34 'security_storage': hasPrivacyConsent('security') ? 'granted' : 'denied',
35 'analytics_storage': hasPrivacyConsent('measurement') ? 'granted' : 'denied',
36 'ad_storage': hasPrivacyConsent('marketing') ? 'granted' : 'denied',
37 'ad_user_data': hasPrivacyConsent('marketing') ? 'granted' : 'denied',
38 'ad_personalization': hasPrivacyConsent('marketing') ? 'granted' : 'denied'
39 });
40 }
41 })()
42 } catch (_err) { /* Do nothing */ }
43</script>
44```

Modifié par tim le 9 mai 2026 à 16:48

Voir le code sur GitHub