Skip to content

Commit d53fe3d

Browse files
authored
Merge pull request #4825 from segmentio/lizkane222-patch-20
Update cookie-validity-update.md A.js Cookie methods
2 parents 2f4908f + 8759423 commit d53fe3d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,15 @@ You can still manually track identity by calling `analytics.identify()` with the
127127
Analytics.js tries to detect when a page is about to be closed and saves pending events to `localStorage`. When the user navigates to another page within the same domain, Analytics.js attempts to send any events it finds in localStorage.
128128

129129
When `disableClientPersistence` is set to `true`, Analytics.js won't store any pending events into `localStorage`.
130+
131+
## Client side cookie methods (get, set, clear)
132+
133+
To access or assign a value to a cookie outside of the standard Segment methods (track/identify/page/group), you can use the following methods. To access the cookie's value, pass an empty `()` at the end of the method. To assign the value, include the string value inside those parenthesis, for example, `('123-abc')`. To clear or remove the value for a specific field, pass in an empty value of its type. For example, for string `('')`, or for object `({})`.
134+
135+
| Field | Cookie Name | Analytics.js Method | Local Storage Method | Set Example | Clear Example |
136+
| ----- | ----------- | ------------------- | -------------------- | --------------- | ------------- |
137+
| `userId` | `ajs_user_id` | `analytics.user().id();` | `window.localStorage.ajs_user_id` | `analytics.user().id('123-abc');` | `analytics.user().id('');` |
138+
| `anonymousId` | `ajs_anonymous_id` | `analytics.user().anonymousId();` | `window.localStorage.ajs_anonymous_id` | `analytics.user().anonymousId('333-abc-456-dfg');` | `analytics.user().anonymousId('');` |
139+
| `user traits` | `ajs_user_traits` | `analytics.user().traits();` | `window.localStorage.ajs_user_traits` | `analytics.user().traits({firstName:'Jane'});` | `analytics.user().traits({});` |
140+
| `groupId` | `ajs_group_id` | `analytics.group().id();` | `window.localStorage.ajs_group_id` | `analytics.group().id('777-qwe-098');` | `analytics.group().id('');` |
141+
| `group traits` | `ajs_group_properties` | `analytics.group().traits()` | `window.localStorage.ajs_group_properties` | `analytics.group().traits({name:'Segment'})` | `analytics.group().traits({})` |

0 commit comments

Comments
 (0)