Set, set once, unset
analytics.setPersonProperties({
email: user.email,
name: user.displayName,
set: { plan: 'pro' },
setOnce: { first_plan: 'free' },
unset: ['trial_ends_at'],
});
| Field | Does |
|---|---|
email |
Sets the person’s email address. null removes it |
name |
Sets the person’s display name. null removes it |
set |
Overwrites the value. A null in set removes the key |
setOnce |
Keeps the earliest value: later setOnce calls for the key do nothing |
unset |
Removes the keys listed |
Values are on the person’s profile, never on event rows, so this is where an email address belongs (What never goes in an event).
Pass the email and name as their own fields
The person’s email address and display name are the reserved person properties $email and
$name, defined by Togo in every project. Pass them as the email and name fields of the call,
as above, and the SDK writes them under those names. Never put an email or name key in set or
setOnce: TypeScript refuses it, and a profile write that carries one has it dropped, reported as
person_property_reserved.
Names starting with $ are reserved for Togo. With a live key the SDK drops one from set,
setOnce or unset, logs a [togo] error naming it, and sends the rest; with a test key it sends
the name, so verify_tracking reports it. Name your own properties without the $, in whatever
spelling your app already uses.
Define a property before you send it
Only defined properties are kept. Every name in set, setOnce and unset must be defined
first — a type and a description — or it is dropped. A property is defined under the name your app
sends, exactly: planType and Plan Type are two properties, so define the one your code uses. A
dropped name’s diagnostic names a defined property it probably means, when there is one. An agent defines one with
update_property_definitions, and
list_properties shows what is
defined already, $email and $name included. The install flow defines the properties your app
sends before it writes the code (Install Togo with your AI agent).
A defined property’s type never changes. Its allowed values and maximum length can be narrowed only while no stored profile holds a value they would refuse.
Before and after sign-in
setPersonProperties() works before identify(). A profile set while the visitor is anonymous —
a lead form’s company size, say — is kept, and carries forward when they sign in.
From the server
The server SDK takes the person as the second argument, the same as track():
analytics.setPersonProperties({ email: user.email, set: { plan: 'pro' } }, { userId: user.id });
Limits
Each call is one profile update, through the same consent gate as track(); an empty call sends
nothing. Values follow the event limits — strings, numbers, booleans or null, at most 1,024
characters a value.
Check it works
Run the call with the test key and check the profile write arrived: Check that events arrive.