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
Clear tracking data ({{ utm.data.value.length }} entries)
137
+
</button>
138
+
</div>
139
+
</template>
140
+
141
+
<script setup>
142
+
const utm = useNuxtUTM()
143
+
144
+
const toggleTracking = (event) => {
145
+
if (event.target.checked) {
146
+
utm.enableTracking()
147
+
} else {
148
+
utm.disableTracking()
149
+
}
150
+
}
151
+
</script>
152
+
```
153
+
154
+
### Accessing UTM Data
155
+
156
+
You can use `useNuxtUTM` composable to access the UTM data:
67
157
68
158
```vue
69
159
<script setup>
70
-
import { useNuxtApp } from 'nuxt/app'
71
-
const { $utm } = useNuxtApp()
160
+
const utm = useNuxtUTM()
161
+
162
+
// Access the collected data
163
+
console.log(utm.data.value)
72
164
</script>
73
165
```
74
166
75
-
Regardless of the option you choose to use the module, the `utm' object will contain an array of UTM parameters collected for use. Each element in the array represents a set of UTM parameters collected from a URL visit, and is structured as follows
167
+
> Remember: You don't need to import the composable because Nuxt imports it automatically.
168
+
169
+
### Data Structure
170
+
171
+
The `data` property contains an array of UTM parameters collected. Each element in the array represents a set of UTM parameters collected from a URL visit, and is structured as follows
76
172
77
173
```json
78
174
[
@@ -104,7 +200,15 @@ Regardless of the option you choose to use the module, the `utm' object will con
104
200
]
105
201
```
106
202
107
-
In the `$utm` array, each entry provides a `timestamp` indicating when the UTM parameters were collected, the `utmParams` object containing the UTM parameters, `additionalInfo` object with more context about the visit, and a `sessionId` to differentiate visits in different sessions.
203
+
Each entry provides a `timestamp` indicating when the UTM parameters were collected, the `utmParams` object containing the UTM parameters, `additionalInfo` object with more context about the visit, and a `sessionId` to differentiate visits in different sessions.
204
+
205
+
### Key Features
206
+
207
+
-**Runtime Control**: Enable/disable tracking dynamically based on user consent
208
+
-**Privacy Friendly**: Respects user preferences and provides clear data management
209
+
-**Persistent Preferences**: Tracking preferences are saved and persist across sessions
210
+
-**Data Clearing**: Ability to completely remove all collected data
211
+
-**Session Management**: Automatically manages sessions to avoid duplicate tracking
0 commit comments