Update expiry date of Mailchimp Pop-up

Mailchimp provides pop-up signup forms. Pop-up signup forms helps to connect the visitor of the website. Please click here to read the tutorial related to mailchimp pop-up signup form.

Mailchimp pop-up uses cookies to limit the number of times each site visitor sees your pop-up form. After the first time a visitor sees the form, it won’t display to them again for another year unless they clear their cookies or open your site in another browser. There is no any settings in the mailchimp to update/change the default expire time of cookie. As a owner of the site, we might want visitor to see the pop-up more frequently rather than once in a year. To update the mailchimp cookie, we shall write the script that overwrites the expiry time set by the mailchimp.

  1. For the first time, when user click the close button of mailchimp and browser reloads, set the expiry time in the localStorage and update the mailchimp expiry date.
  2. We can’t get the expiration date of a cookie through javascript. So, storing the expiry time in the local storge helps to compare the expiry time with current time.
  3. Next time when user visits the website, local storage expiry date is compared against the current date. If the current date is greater than expiry time, there will be no mailchimp cookie and localStorage is deleted. In my script, I have set the cookie expiry date to 24 hours.



Hits: 218