1

From:

https://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-id#cookie_update

Cookie update

When cookie_update is set to true (the default value), gtag.js will update cookies on each page load. This will update the cookie expiration to be set relative to the most recent visit to the site. For example, if cookie expiration is set to one week, and a user visits using the same browser every five days, the cookie expiration will be updated on each visit and so will effectively never expire.

When set to false, cookies are not updated on each page load. This has the effect of cookie expiration being relative to the first time a user visited the site.

Example of Analytics Cookie

enter image description here

QUESTION

What happens if a user's Analytics gtag.js cookie expires? I'm assuming he will get a brand new one on the next visit.

But will he receive a different user unique ID on this next brand new cookie? Or will the user's unique ID stored on the expired cookie persist on the new cookie?

1 Answer 1

1

The ID is contained in the cookie. When the cookie expires, the browser automatically deletes it and the web site doesn't get it back on the next visit.

Therefore, once the cookie expires, there is no way for Google Analytics to know what the old ID was. The new cookie will get a brand new ID in it.

When cookie_update is set to true, the cookie will get a new expiry on each pageview, but the data inside the cookie will stay the same. Having the cookie updated on each pageview is the best way to ensure that cookie ids stick around for as long as possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.