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 | any | 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