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
+32-21Lines changed: 32 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,13 +20,9 @@ Nuxt Scripts provides many features you can easily
20
20
implement within your Nuxt app. If you're using GTM for Google Tag Manager, you can use the `useScriptGoogleAnalytics` composable instead.
21
21
::
22
22
23
-
### Nuxt Config Setup
23
+
##Loading Globally
24
24
25
-
The simplest way to load Google Tag Manager globally in your Nuxt App is to use Nuxt config. Alternatively you can directly
26
-
use the [useScriptGoogleTagManager](#useScriptGoogleTagManager) composable.
27
-
28
-
If you don't plan to send custom events you can use the [Environment overrides](https://nuxt.com/docs/getting-started/configuration#environment-overrides) to
29
-
disable the script in development.
25
+
If you'd like to avoid loading the analytics in development, you can use the [Environment overrides](https://nuxt.com/docs/getting-started/configuration#environment-overrides) in your Nuxt config.
Please follow the [Registry Scripts](/docs/guides/registry-scripts) guide to learn more about advanced usage.
92
+
Please follow the [Registry Scripts](/docs/guides/registry-scripts) guide to learn more about `proxy`.
93
+
94
+
### Guide: Sending Page Events
95
+
96
+
If you'd like to manually send page events to Google Tag Manager, you can use the `proxy` with the [useScriptEventPage](/docs/api/use-script-event-tag) composable.
97
+
This composable will trigger the provided function on route change after the page title has been updated.
98
+
99
+
```ts
100
+
const { proxy } =useScriptGoogleTagManager({
101
+
id: 'YOUR_ID'// id is only needed if you haven't configured globally
102
+
})
103
+
104
+
useScriptEventPage((title, path) => {
105
+
// triggered on route change after title is updated
0 commit comments