If you have to old Google Analytics script on your website, then you can specify on the script an overwrite of the default value of two years. The value specifies the cookie expiration, in seconds.

ga('create', 'UA-XXXX-Y', {'cookieExpires': 31536000});


<script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','','ga'); ga('create', 'UA-XXXX-Y', {'cookieExpires': 31536000,'cookieUpdate': 'false'}); ga('send', 'pageview');</script>

You may also need to turn off the automatic update of the expiration date, so if a user returns to the site, then the expiration is not again set to a year.

ga('create', 'UA-XXXX-Y', {'cookieUpdate': 'false'});

  • Go to your global Google Analytics Page View Tag.

  • Check the box: Enable overriding settings in this tag

  • Roll out more settings

  • Roll out Fields to Set

  • Press: Add Field and field our the two fields as shown below.


Using the new gtag js

gtag('config', 'GA_MEASUREMENT_ID', { 'cookie_expires': 31536000});

Did this answer your question?