Create Cookie On the Click of an Element Within Your Popup

If you are not already familiar with using custom JavaScript, check out our   getting started guide.


Let's say you have an Auto Open Popup that triggers as soon as users visit your site - no matter what page the user hits your site on, you want the popup to open - thus, it's a sitewide popup. Inside the popup is two images: clicking either one of the images puts you down Path A or Path B.

Once the user selects their path, you don't want them to continuously be spammed by your popup, so you have to set the Cookie on the click of the image element - this method works with any HTML element (text, image, link, etc.).

Setup Your Cookie

First,  setup your Cookie your using the Manual JavaScript Cookie Creation Event in the Popup Editor.

After clicking Add, you will be able to customize every aspect of how your Cookie will behave. For detailed explanations on all of the Cookie Settings and features, check out the   Cookie Settings and Features Doc.

Add and Edit Manual JavaScript

Add the code below to your functions.php, making sure to input the correct CSS Selector - if you're not familiar with CSS Selectors, check out our Getting CSS Selectors doc. You should include any "#" and "." with your selectors below. Also, you'll need to change the Popup ID #, find your Popup ID # in the All Popups Screen: