Skip to content

Commit d42e49e

Browse files
dannyshmueliclaude
andcommitted
docs: add Step 2d for aa.set() global properties
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9a445f1 commit d42e49e

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

skill/SKILL.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff 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
248273
After adding tracking, verify it works:

0 commit comments

Comments
 (0)