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
Umami v2.18.0+ supports setting unique session IDs using the `identify` function. You can pass either a string (unique ID) or an object with session data:
153
+
154
+
```ts
155
+
const { proxy } =useScriptUmamiAnalytics({
156
+
websiteId: 'YOUR_WEBSITE_ID'
157
+
})
158
+
159
+
// Using a unique string ID
160
+
proxy.identify('user-12345')
161
+
162
+
// Using session data object
163
+
proxy.identify({
164
+
userId: 'user-12345',
165
+
plan: 'premium'
166
+
})
167
+
```
168
+
169
+
### Data Filtering with beforeSend
170
+
171
+
The `beforeSend` option allows you to inspect, modify, or cancel data before it's sent to Umami. This is useful for implementing custom privacy controls or data filtering:
172
+
173
+
```ts
174
+
useScriptUmamiAnalytics({
175
+
websiteId: 'YOUR_WEBSITE_ID',
176
+
beforeSend: (type, payload) => {
177
+
// Log what's being sent (for debugging)
178
+
console.log('Sending to Umami:', type, payload)
179
+
180
+
// Filter out sensitive data
181
+
if (payload.url&&payload.url.includes('private')) {
182
+
returnfalse// Cancel send
183
+
}
184
+
185
+
// Modify payload before sending
186
+
return {
187
+
...payload,
188
+
referrer: ''// Remove referrer for privacy
189
+
}
190
+
}
191
+
})
192
+
```
193
+
194
+
You can also provide a string with the name of a globally defined function:
0 commit comments