Appearance
Property Schema ​
Properties are attributes that can be attached to events or groups. They provide additional context about the action or entity being tracked.
Configuration ​
Field | Type | Required | Description |
---|---|---|---|
name | string | yes | Property name |
description | string | no | Property context description |
type | string , string[] , boolean , Boolean[] , number , number[] , oneOf | yes | Expected TypeScript type |
defaultValue | string , string[] , boolean , Boolean[] , number , number[] | no | Default value to use if one is not provided |
optional | boolean | no | Mark property as optional |
Type Options ​
Properties support various type configurations:
- Simple Types:
string
,number
,boolean
- Array Types:
string[]
,number[]
,boolean[]
- Enum Types:
["value1", "value2"]
Note: Properties can be a function, promise, or a function returning a promise. Function properties are re-evaluated for every tracked event, which is useful for auto-tracking dynamic values like the current page url.
typescript
tracker.setProperties('EveryEvent', {
// Functions are re-evaluated for each tracked event
Url: () => window.location.href,
});
Example ​
yaml
properties:
- name: Page Name
description: The name of the page that was viewed.
type: string
- name: User Role
description: The role of the user.
type: [admin, member, guest]
- name: View Count
description: Number of times the item was viewed.
type: number
optional: true
Optional & passthrough properties ​
By default, all properties defined on an event are required when tracking that event. Properties are only non-required when marked with optional: true
.
Arbitrary properties, or properties that don't exist in the event schema, are only allowed to be tracked when the event is marked with passthrough: true
.