Test for cookie values on the Site Area

Example Use Case

Sometimes we may need to check for a specific condition to occur on every page visit, but that condition might be related to the options offered in the Site Area GUI.

A common need is to verify a cookie value for a user to be bucketed into the test, but if this cookie value changes the experience should no longer be shown to the visitor. For example, we might want to show a coupon only one time; or, the opposite. 

What we would need is a JavaScript Condition that checks for the cookie value and the URL value at the same time.

Code

Place the following code in the Site Area as a JavaScript condition in the Include Tab.  Make sure you modify the code with the correct values to check in the cookie and the cookie name as specified in the cookie comments.

See the Pen.

Have more questions? Submit a request

Comments