Skip to content

Commit c7fc6db

Browse files
authored
Merge pull request #6001 from segmentio/bcaudillo-patch-7
update documentation on grabbing specific traits
2 parents 70c81c4 + 68daac4 commit c7fc6db

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/connections/sources/catalog/libraries/website/javascript/cookie-validity-update.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ To access or assign a value to a cookie outside of the standard Segment methods
140140
<tr style="background-color: #fafbff; font-size: 10px;">
141141
<th>FIELD</th>
142142
<th>COOKIE NAME</th>
143-
<th>ANALYTICS.JS METHOD</th>
144-
<th>LOCAL STORAGE METHOD</th>
143+
<th>ANALYTICS.JS GET METHOD</th>
144+
<th>LOCAL STORAGE GET METHOD</th>
145145
<th>SET EXAMPLE</th>
146146
<th>CLEAR EXAMPLE</th>
147147
</tr>
@@ -187,6 +187,12 @@ To access or assign a value to a cookie outside of the standard Segment methods
187187
</tr>
188188
</table>
189189

190+
To retrieve a specific user trait using the Analytics.js Get method, you can access the trait by invoking `analytics.user().traits().firstName`. This returns the firstName trait of the user.
191+
192+
To retrieve a specific group trait, you can use the method `analytics.group().traits().companyName`. This returns the companyName trait of the group.
193+
194+
When you access specific traits stored in the browser's localStorage, you need to utilize the [JSON.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse){:target="_blank"} method because the stored data is typically in string format.
195+
190196
## Storage Priority
191197

192198
By default, Analytics.js uses `localStorage` as its preferred storage location, with Cookies as a fallback when `localStorage` is not available or not populated. An in-memory storage is used as a last fallback if all the previous ones are disabled.

0 commit comments

Comments
 (0)