zesty.io

Product

Use Cases

Integrations

Learn

How to Personalize User Experience with Session Variables

When a user has cookies disabled, or their ad blocker blocks cookies, your best to use session variables to ensure personalization works for them. This guide will show you how to use session variables

Parsley access to session variables should not be used on statically cached pages.

In this guide you will learn how to create page personalization, using session variables, on the Zesty platform. We will be modifying the loader file and a view file to create the most basic form of personalization.

There are three key components to executing personalization. The URL, the Session Variable, and the Business Logic. Let's start by looking at how to format the URL.

The URL

The url will contain the key to personalization, it is simply stored in a Get variable. A Get variable can be appended to the end of any URL. In our example, let's use st, short for session test.

Note: when you setup links with advertisers, just append ?st=developer or ?st=marketeretc. and you can custom curate any experience you want to deliver.

Easy right? Now let's store that value to a session variable.

The Session Variable

Session variables are single references stored to memory on Zesty servers. Once a session variable is set, it can be accessed with Zesty's reference language, parsley. Parsley provides a simple way to set and access cookies, which looks like $_variable = 'hello world'. Note the $_ denotes the variable a session variable, where are variable $ without the _ underscore is only available in a single page load.

In this example, we are going to store the Get variable passed by the URL to our session variable. To ensure we capture this on any page, we are going to put our code in the loader view. From the Code Editor in your Satellite, open the loader view file, and enter this line of code:

Open the loader view file and add:

Note: the name of the session variable doesn't effect the result, but the name cannot have spaces or abnormal characters. Session variables can also be overwritten, so on a page for marketers you could overwrite the variable to {{$_sesvar = 'marketers'}}, and then start targeting your language to marketers.

The Business Logic

In our URL https://mydomain.com/page/?st=developer we are passing the value developer and capturing that value into our session variable. With an if statement, we are going to check the session variable's value against our desired match developer. 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!

Start Here

We will listen to your needs and walk you through how Zesty can help your team.

Connect with Content Experts

Book a free 15-minute consultation with a content expert. Discuss your application, pain points and requirements. Understand how Zesty's lower total cost of ownership, features, functionality can elevate your business by creating extraordinary digital experiences.

Trusted By

zesty customer logo Sonyzesty customer logo Rocket Leaguezesty customer logo Singlifezesty customer logo Phoenix Sunszesty customer logo Wattpad

Enter your details to connect with a Content Expert

First Name

Last Name

Email

Phone (optional)

Company

Please tell us about your project (optional)

G2 MOMENTUM LEADER

zesty customer logo zesty customer logo zesty customer logo zesty customer logo