File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -243,6 +243,31 @@ npx @agent-analytics/cli query my-site \
243243 --group-by properties.source --metrics event_count
244244```
245245
246+ ## Step 2d: Set global properties
247+
248+ Use ` aa.set() ` to attach properties to ALL subsequent events without repeating them in every ` track() ` call:
249+
250+ ``` js
251+ // After login, tag all future events with the user's plan
252+ window .aa ? .set ({ plan: ' pro' , team: ' acme' });
253+
254+ // These events now include plan='pro' and team='acme' automatically
255+ window .aa ? .track (' feature_used' , { feature: ' export' });
256+ window .aa ? .track (' cta_click' , { id: ' upgrade' });
257+ ` ` `
258+
259+ **How it works:**
260+ - Merge order: auto-collected < UTM < global (set) < event-specific. Event-specific properties always win.
261+ - Multiple ` set ()` calls merge — ` set ({a: 1 }); set ({b: 2 })` results in ` {a: 1 , b: 2 }`
262+ - Remove a key: ` aa .set ({ plan: null })`
263+ - In-memory only — does not persist across page reloads (use ` identify ()` for cross-session user identity)
264+ - Zero overhead when not used
265+
266+ **When to use:**
267+ - After login/signup: ` aa .set ({ plan: user .plan , role: user .role })`
268+ - Feature flags: ` aa .set ({ feature_flag_x: ' variant_b' })`
269+ - Any context that applies to all events for the rest of the session
270+
246271## Step 3: Test immediately
247272
248273After adding tracking, verify it works:
You can’t perform that action at this time.
0 commit comments