From 489d5b30747869fecf0a5b054ad1381ed8cc1da8 Mon Sep 17 00:00:00 2001 From: Liz Kane <68755692+lizkane222@users.noreply.github.com> Date: Tue, 4 Jun 2024 18:05:04 -0700 Subject: [PATCH 1/7] Update identity.md More info on Saving Traits to Context Object --- .../catalog/libraries/website/javascript/identity.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/connections/sources/catalog/libraries/website/javascript/identity.md b/src/connections/sources/catalog/libraries/website/javascript/identity.md index 8f1caef6ec..82df973cb8 100644 --- a/src/connections/sources/catalog/libraries/website/javascript/identity.md +++ b/src/connections/sources/catalog/libraries/website/javascript/identity.md @@ -168,6 +168,15 @@ analytics.track('Clicked Email', { 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. +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), you'd need to dynamically add that data into the event method in order to include the traits within the event's `context.traits` object. For example, this method uses the Analytics traits method to dynamically add the `traits` cookie into the `Button Clicked` Track event : `analytics.track("Button Clicked", {button:"submit"}, {traits:analytics.user().traits()})`. + +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. +- [**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]); +- [**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]); +- [**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]); +- [**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]); + +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. ## Clearing Traits From c14382f4eb0dc1a0a7f960a396ea1bc0c416f7f0 Mon Sep 17 00:00:00 2001 From: prigiattiperrut <47340158+prigiattiperrut@users.noreply.github.com> Date: Mon, 27 Jan 2025 13:56:57 +0000 Subject: [PATCH 2/7] Update identity.md --- .../sources/catalog/libraries/website/javascript/identity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connections/sources/catalog/libraries/website/javascript/identity.md b/src/connections/sources/catalog/libraries/website/javascript/identity.md index 82df973cb8..4b2ba54efc 100644 --- a/src/connections/sources/catalog/libraries/website/javascript/identity.md +++ b/src/connections/sources/catalog/libraries/website/javascript/identity.md @@ -168,7 +168,7 @@ analytics.track('Clicked Email', { 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. -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), you'd need to dynamically add that data into the event method in order to include the traits within the event's `context.traits` object. For example, this method uses the Analytics traits method to dynamically add the `traits` cookie into the `Button Clicked` Track event : `analytics.track("Button Clicked", {button:"submit"}, {traits:analytics.user().traits()})`. +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 traits within the event's context.traits object. 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. - [**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]); From 7e2b1ff51d759229f8d7f00b554c2a0406888f61 Mon Sep 17 00:00:00 2001 From: pwseg Date: Thu, 6 Mar 2025 13:39:11 -0600 Subject: [PATCH 3/7] some cleanup and rewording --- .../libraries/website/javascript/identity.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/connections/sources/catalog/libraries/website/javascript/identity.md b/src/connections/sources/catalog/libraries/website/javascript/identity.md index 4b2ba54efc..7a0e9d3021 100644 --- a/src/connections/sources/catalog/libraries/website/javascript/identity.md +++ b/src/connections/sources/catalog/libraries/website/javascript/identity.md @@ -168,15 +168,17 @@ analytics.track('Clicked Email', { 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. -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 traits within the event's context.traits object. +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. -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. -- [**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]); -- [**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]); -- [**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]); -- [**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]); +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: + +- [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])`; +- [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]); +- [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]); +- [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]); + +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. -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. ## Clearing Traits From 3ae73603dc6edd002b3691642b4013cfb1ca4414 Mon Sep 17 00:00:00 2001 From: pwseg Date: Thu, 6 Mar 2025 13:40:21 -0600 Subject: [PATCH 4/7] update some relative links --- .../catalog/libraries/website/javascript/identity.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/connections/sources/catalog/libraries/website/javascript/identity.md b/src/connections/sources/catalog/libraries/website/javascript/identity.md index 7a0e9d3021..f0c94112b3 100644 --- a/src/connections/sources/catalog/libraries/website/javascript/identity.md +++ b/src/connections/sources/catalog/libraries/website/javascript/identity.md @@ -172,10 +172,10 @@ By default, non-Identify events (like Track or Page) **don't automatically colle 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: -- [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])`; -- [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]); -- [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]); -- [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]); +- [Identify](/docs/connections/spec/identify/) - The [Analytics.js Identify](/docs/connections/sources/catalog/libraries/website/javascript/#identify) method follows this format : `analytics.identify([userId], [traits], [options], [callback])`; +- [Track](/docs/connections/spec/track/) - The [Analytics.js Track](/docs/connections/sources/catalog/libraries/website/javascript/#track) method follows this format : analytics.track(event, [properties], [options], [callback]); +- [Page](/docs/connections/spec/page/) - The [Analytics.js Page](/docs/connections/sources/catalog/libraries/website/javascript/#page) method follows this format : analytics.page([category], [name], [properties], [options], [callback]); +- [Group](/docs/connections/spec/group/) - The [Analytics.js Group](/docs/connections/sources/catalog/libraries/website/javascript/#group) method follows this format : analytics.group(groupId, [traits], [options], [callback]); 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. From c8598d0e033982004cd6f1867c6709504d6c9aae Mon Sep 17 00:00:00 2001 From: pwseg Date: Thu, 6 Mar 2025 13:40:44 -0600 Subject: [PATCH 5/7] function formatting --- .../catalog/libraries/website/javascript/identity.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/connections/sources/catalog/libraries/website/javascript/identity.md b/src/connections/sources/catalog/libraries/website/javascript/identity.md index f0c94112b3..8d7884700d 100644 --- a/src/connections/sources/catalog/libraries/website/javascript/identity.md +++ b/src/connections/sources/catalog/libraries/website/javascript/identity.md @@ -173,9 +173,9 @@ By default, non-Identify events (like Track or Page) **don't automatically colle 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: - [Identify](/docs/connections/spec/identify/) - The [Analytics.js Identify](/docs/connections/sources/catalog/libraries/website/javascript/#identify) method follows this format : `analytics.identify([userId], [traits], [options], [callback])`; -- [Track](/docs/connections/spec/track/) - The [Analytics.js Track](/docs/connections/sources/catalog/libraries/website/javascript/#track) method follows this format : analytics.track(event, [properties], [options], [callback]); -- [Page](/docs/connections/spec/page/) - The [Analytics.js Page](/docs/connections/sources/catalog/libraries/website/javascript/#page) method follows this format : analytics.page([category], [name], [properties], [options], [callback]); -- [Group](/docs/connections/spec/group/) - The [Analytics.js Group](/docs/connections/sources/catalog/libraries/website/javascript/#group) method follows this format : analytics.group(groupId, [traits], [options], [callback]); +- [Track](/docs/connections/spec/track/) - The [Analytics.js Track](/docs/connections/sources/catalog/libraries/website/javascript/#track) method follows this format : `analytics.track(event, [properties], [options], [callback])`; +- [Page](/docs/connections/spec/page/) - The [Analytics.js Page](/docs/connections/sources/catalog/libraries/website/javascript/#page) method follows this format : `analytics.page([category], [name], [properties], [options], [callback])`; +- [Group](/docs/connections/spec/group/) - The [Analytics.js Group](/docs/connections/sources/catalog/libraries/website/javascript/#group) method follows this format : `analytics.group(groupId, [traits], [options], [callback])`; 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. From 103247c9e16be4387651e0c12928b7083a8064b0 Mon Sep 17 00:00:00 2001 From: pwseg Date: Thu, 6 Mar 2025 13:42:43 -0600 Subject: [PATCH 6/7] fix typo --- .../sources/catalog/libraries/website/javascript/identity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connections/sources/catalog/libraries/website/javascript/identity.md b/src/connections/sources/catalog/libraries/website/javascript/identity.md index 8d7884700d..804f13f9c1 100644 --- a/src/connections/sources/catalog/libraries/website/javascript/identity.md +++ b/src/connections/sources/catalog/libraries/website/javascript/identity.md @@ -177,7 +177,7 @@ Each Analytics.js method has an `options` parameter where you can pass the `cont - [Page](/docs/connections/spec/page/) - The [Analytics.js Page](/docs/connections/sources/catalog/libraries/website/javascript/#page) method follows this format : `analytics.page([category], [name], [properties], [options], [callback])`; - [Group](/docs/connections/spec/group/) - The [Analytics.js Group](/docs/connections/sources/catalog/libraries/website/javascript/#group) method follows this format : `analytics.group(groupId, [traits], [options], [callback])`; -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. +Adding traits to events is especially useful if you're using [Actions destinations](/docs/connections/destinations/actions/), since it makes those traits available for mapping in the destination’s configuration. ## Clearing Traits From a2690141c2e74195b065771789cc85b7607e7a3d Mon Sep 17 00:00:00 2001 From: pwseg Date: Thu, 6 Mar 2025 13:43:37 -0600 Subject: [PATCH 7/7] add one more link --- .../sources/catalog/libraries/website/javascript/identity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connections/sources/catalog/libraries/website/javascript/identity.md b/src/connections/sources/catalog/libraries/website/javascript/identity.md index 804f13f9c1..b8f915a88c 100644 --- a/src/connections/sources/catalog/libraries/website/javascript/identity.md +++ b/src/connections/sources/catalog/libraries/website/javascript/identity.md @@ -170,7 +170,7 @@ This appends the `plan_id` trait to this Track event. This does _not_ add the na 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. -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: +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](/docs/connections/spec/) when adding traits, like in these examples: - [Identify](/docs/connections/spec/identify/) - The [Analytics.js Identify](/docs/connections/sources/catalog/libraries/website/javascript/#identify) method follows this format : `analytics.identify([userId], [traits], [options], [callback])`; - [Track](/docs/connections/spec/track/) - The [Analytics.js Track](/docs/connections/sources/catalog/libraries/website/javascript/#track) method follows this format : `analytics.track(event, [properties], [options], [callback])`;