Skip to content

Commit 7989494

Browse files
committed
cookie validity update cleanup
1 parent 005cde1 commit 7989494

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ redirect_from: '/connections/sources/catalog/libraries/website/javascript/persis
44
strat: ajs
55
---
66

7-
This page explains what data Analytics.js stores on the client and how to override and change what and how this data is stored.
7+
This page explains what data Analytics.js stores on the client and shows you how to modify or override that storage behavior.
88

99
## Segment ID persistence
1010

1111
<!-- Note: 1st 2 paragraphs copied from identity.md -->
1212

13-
To ensure high fidelity, first-party customer data, Segment writes the user's IDs to the user's local storage and uses that as the Segment ID on the cookie whenever possible. Local storage is for storing this type of first-party customer information.
13+
To ensure high-fidelity, first-party customer data, Segment writes the user's IDs to the user's local storage and uses them as the Segment ID in the cookie whenever possible. Local storage is intended for storing first-party customer information.
1414

15-
If a user returns to your site after the cookie expires, Analytics.js looks for an old ID in the user's `localStorage`, and if one is found, it sets as the user's ID again in the new cookie. If a user clears their cookies _and_ `localStorage`, all of the IDs are removed, and the user gets a completely new [`anonymousID`](/docs/connections/sources/catalog/libraries/website/javascript/identity/#anonymous-ids) when they next visit the page.
15+
If a user returns to your site after the cookie expires, Analytics.js looks for an old ID in the user's `localStorage`, and if one is found, it sets it as the user's ID again in the new cookie. If a user clears their cookies _and_ `localStorage`, all of the IDs are removed, and the user gets a completely new [`anonymousID`](/docs/connections/sources/catalog/libraries/website/javascript/identity/#anonymous-ids) when they next visit the page.
1616

1717
### Cookie settings
1818

@@ -26,7 +26,7 @@ Here is the full list of available parameters with their default values:
2626
| Parameter | Description | Default value |
2727
| --- | --- | --- |
2828
| `domain` | The domain to set the cookie to. This must match the domain of the JavaScript origin. If an Analytics.js cookie already exists at the top-level domain, Segment carries the same cookie value to any subdomains, despite `domain` configuration. | Top-level domain |
29-
| `maxage` | The maximum amount of time in days before the cookie expires. Browsers may clear cookies before this elapses. | 1 year |
29+
| `maxage` | The maximum amount of time in days before the cookie expires. Browsers may clear cookies before this time elapses. | 1 year |
3030
| `path` | The path the cookie is valid for. | `"/"` |
3131
| `sameSite` | This prevents the browser from sending the cookie along with cross-site requests. | `Lax` |
3232
| `secure` | This determines whether cookies can only be transmitted over secure protocols such as https. | `false` |
@@ -60,7 +60,7 @@ To set cookie values using the [NPM package](https://github.com/segmentio/analyt
6060
})
6161
```
6262
> info ""
63-
> Chrome has a maximum limit of 400 days for cookies. If a value is set beyond that, then Chrome sets the upper limit to 400 days instead of rejecting it. Visit Chrome's [docs](https://developer.chrome.com/blog/cookie-max-age-expires/){:target="blank"} to learn more.
63+
> Chrome has a maximum limit of 400 days for cookies. If a value is set beyond that, then Chrome sets the upper limit to 400 days instead of rejecting it. Visit [Chrome's docs](https://developer.chrome.com/blog/cookie-max-age-expires/){:target="blank"} to learn more.
6464
6565
### Device-mode destination cookies
6666

@@ -144,13 +144,13 @@ You can still manually track identity by calling `analytics.identify()` with the
144144

145145
### Event retries
146146

147-
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.
147+
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`.
148148

149149
When `disableClientPersistence` is set to `true`, Analytics.js won't store any pending events into `localStorage`.
150150

151151
## Client-side cookie methods (get, set, clear)
152152

153-
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 `({})`.
153+
To access or assign a value to a cookie outside of the standard Segment methods (Track, Identify, Page, and 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 `({})`.
154154

155155
<table class="horizontal-scroll">
156156
<tr style="background-color: #fafbff; font-size: 10px;">
@@ -203,17 +203,17 @@ To access or assign a value to a cookie outside of the standard Segment methods
203203
</tr>
204204
</table>
205205

206-
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.
206+
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.
207207

208-
To retrieve a specific group trait, you can use the method `analytics.group().traits().companyName`. This returns the companyName trait of the group.
208+
To retrieve a specific group trait, you can use the method `analytics.group().traits().companyName`. This returns the `companyName` trait of the group.
209209

210-
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.
210+
When you access specific traits stored in the browser's `localStorage`, you need to use 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.
211211

212-
## Storage Priority
212+
## Storage priority
213213

214214
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.
215215

216-
Default Storage Priority:
216+
Default storage priority:
217217

218218
```md
219219
LocalStorage -> Cookie -> InMemory

0 commit comments

Comments
 (0)