Skip to content

Commit 7cf726b

Browse files
authored
update documentation on grabbing specific traits
1 parent ccaf648 commit 7cf726b

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 will return the firstName trait of the user.
191+
192+
Similarly, to retrieve a specific group trait, you can use the method `analytics.group().traits().companyName`. This will return the companyName trait of the group.
193+
194+
When accessing specific traits stored in the browser's localStorage, you'll need to utilize the [JSON.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) method due to the fact that 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)