Personalization with JavaScript Cookies

In the event where you want to store a cookie based on a user action without passing a link, you would need to use JavaScript. This guide explains how to setup cookies using JavaScript and later how to use logic to control personalization.

Setting up the JavaScript

In Zesty code editor, create a JavaScript file called cookies.js and paste this code:

When the file is setup, you may now make JavaScript calls to set and read cookies.

Example usage:

The Business Logic

With an if statement, we are going to check the cookie's value to returned customized content. If it's a match, we will show one type of content, otherwise we will show our default content. It's quick to implement, let's take a look at the code.

It's that easy, have fun!