You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/scripts/tracking/google-tag-manager.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,3 +232,37 @@ function sendConversion() {
232
232
`useScriptGoogleTagManager` initialize Google Tag Manager by itself. This means it pushes the `js`, `config` and the `gtm.start` events for you.
233
233
234
234
If you need to configure GTM before it starts. For example, [setting the consent mode](https://developers.google.com/tag-platform/security/guides/consent?consentmode=basic). You can use the `onBeforeGtmStart` hook which is run right before we push the `gtm.start` event into the dataLayer.
235
+
236
+
```vue
237
+
const { proxy } = useScriptGoogleTagManager({
238
+
onBeforeGtmStart: (gtag) => {
239
+
// set default consent state to denied
240
+
gtag('consent', 'default', {
241
+
'ad_user_data': 'denied',
242
+
'ad_personalization': 'denied',
243
+
'ad_storage': 'denied',
244
+
'analytics_storage': 'denied',
245
+
'wait_for_update': 500,
246
+
})
247
+
248
+
// if consent was already given, update gtag accordingly
0 commit comments