You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This appends the `plan_id` trait to this Track event. This does _not_ add the name or email, since those traits were not added to the `context` object. You must do this for every following event you want these traits to appear on, as the `traits` object does not persist between calls.
170
170
171
-
Depending on your use case, this step is optional. Since all non-Identify events do not automatically collect the client's available user traits, see [this table](https://segment.com/docs/connections/spec/common/#:~:text=%E2%9C%85-,traits,%E2%9C%85,-userAgent), if you would like to have traits sent to identify() events appended to subsequent calls (e.g., page, track), you'd need to dynamically add that data into the event method in order to include the traitswithin the event's context.traits object.
171
+
By default, non-Identify events (like Track or Page) **don't automatically collect user traits** from previous Identify calls. To include traits from an `identify()` event in later events, you'll need to add them manually to the `context.traits` object within the `options` parameter.
172
172
173
-
You can technically pass the client's available traits within any of Segment events' `context` object. When doing so, please make sure to reference each event method's Spec documentation, listed below, as well as the method's format. As stated above, each Segment event method has an `options` parameter, which is where you can add the `traits` data. Here's the associated documentation to reference for those events and their formats.
174
-
- [**Spec Identify**](https://segment.com/docs/connections/spec/identify/) - The [Analytics.js Identify](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#identify) method follows this format : analytics.identify([userId], [traits], [options], [callback]);
175
-
- [**Spec Track**](https://segment.com/docs/connections/spec/track/) - The [Analytics.js Track](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#track) method follows this format : analytics.track(event, [properties], [options], [callback]);
176
-
- [**Spec Page**](https://segment.com/docs/connections/spec/page/) - The [Analytics.js Page](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#page) method follows this format : analytics.page([category], [name], [properties], [options], [callback]);
177
-
- [**Spec Group**](https://segment.com/docs/connections/spec/group/) - The [Analytics.js Group](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#group) method follows this format : analytics.group(groupId, [traits], [options], [callback]);
173
+
Each Analytics.js method has an `options` parameter where you can pass the `context.traits` object, but each method has a specific format. Follow the formats in the Segment Spec when adding traits, like in these examples:
174
+
175
+
- [Identify](/docs/connections/spec/identify/) - The [Analytics.js Identify](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#identify) method follows this format : `analytics.identify([userId], [traits], [options], [callback])`;
176
+
- [Track](/docs/connections/spec/track/) - The [Analytics.js Track](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#track) method follows this format : analytics.track(event, [properties], [options], [callback]);
177
+
- [Page](/docs/connections/spec/page/) - The [Analytics.js Page](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#page) method follows this format : analytics.page([category], [name], [properties], [options], [callback]);
178
+
- [Group](https://segment.com/docs/connections/spec/group/) - The [Analytics.js Group](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/#group) method follows this format : analytics.group(groupId, [traits], [options], [callback]);
179
+
180
+
Adding traits to events is especially useful if you're using [Actions destination](/docs/connections/destinations/actions/), since it makes those traits available for mapping in the destination’s configuration.
178
181
179
-
Passing the user's `traits` into other events can be useful when an [Actions destination](https://segment.com/docs/connections/destinations/actions/) is connected, as those fields would then be available to be mapped within the destination's mappings.
0 commit comments