The Power of Personalization: Context Data

Apr 29, 2021
Carson Long

Trying to best target your consumer? The core of marketing personalization is access to information about the consumer. When was the last time they interacted with your brand? Not sure? MessageGears helps you get the answers to these questions in real time.  

For most senders not using MessageGears, access to that consumer information stops with each message sent. This, combined with the fact that you may be using old data, means each message is potentially outdated as soon as it’s sent. 

However, marketing personalization is only as useful as the data it can access. That’s why MessageGears Context Data gives our users the power of personalization with real-time data. 

Context Data Walkthrough

Let’s jump right in and see how one of our tech-savvy enterprise marketers would use Context Data to power personalized messaging today! 

In this example, City & Glory, a retail company, wants to include personalized information and store information within one template. The customer information is accessed through audience data and the store information is accessed through Context Data, as this data is stored in separate tables. MessageGears Segment and Message must be activated for these features.

Audiences and Customer Data

Here we have an audience that accesses customer data. It’s important that the audience includes at least one referenceable field for the context data to look up. In this case, the audience contains a field called Preferred_Store, which is a number value that will correlate to the Store_ID within our Context Data. When setting up Context Data with Audience Data, a referenceable column is necessary. We can “Preview” the audience here to ensure the data is being processed correctly. 

Creating Context Data

Creating Context Data works similarly to creating an audience. We can create Context Data through a SQL query or an API query in MessageGears Message. We’ve used a quick SQL query to add our Context Data in this case. 

Below, we can see the data “Preview” and ensure the Context Data query executed successfully. 

In the case of this example, the store_number column in the Context Data is critical. The PreferredStore column from the audience references the store_number column of the Context Data. This related column ensures that the appropriate store information is rendered within our email. 

Adding Audience Data and Context Data to the Template

Now, we are going to add our audience to our sample data set to ensure that our Context Data renders properly before we launch our campaign. 

After we create our new template, let’s select Setup Personalization from the Template Overview screen. 

Then from the Sample Data screen above, we can click Configure Sample Data, which opens an interface to select an audience and Context Data to use within the template. Here, you can easily build your Sample Audience or select an audience you already have in the system. 

Using the Drag-and-Drop Editor

Now, we’re going to jump into our intuitive drag-and-drop editor to craft our marketing message for our audience. This is where we can use Context Data to power personalization for each recipient in our real-time data. 

Let’s add it into the template by dragging the Text widget onto the template. 

Using FreeMarker, we can add our Context Data to the template in order to personalize our message with this one line of code: 

<#assign myData = ContextData['Entry[store_number="${Recipient.PreferredStore}"]']>

This statement selects the correct store information from the table “myData” referenced in the Context Data configuration to access specific fields of data from that table. The Store_information table that the Context Data is accessing has a column called “address.” To render that information on the screen, we have to use the following FreeMarker format: ${myData.address}

When referencing audience data, the Merge Tags feature in the Drag-and-Drop editor provides a quick way to input personalized data as well. 

The code used in the example below is:

Head on over to ${myData.store_name} at ${myData.address}, ${}, ${} for fresh savings!

Let’s save the template and preview the results using the sample audience preview. With the sample audience preview, we can cycle through multiple sample records to confirm that the proper store information displays within the header too. 

A customer living in Charlotte would receive the following creative:

The creative for a customer in Asheville would look like:

Here in the Preview, we can see that the Context Data renders successfully. Great job, you made it! It ‘s important to note that if we have a national or global audience, the locations will change based on the data stored for them, creating their personalized emails. 


With MessageGears sitting securely on top of their data, users successfully utilize context data for real-time data in cross-channel campaigns, bringing the power of real-time data into each message they send. 

MessageGears’ goal is to eliminate the barriers that keep marketers from effectively using their data. By using real-time data and information to power consumer experiences, marketers can build better, more interactive messaging campaigns that connect with their customers on a more personal level. 

If you are interested in unleashing the power of your data in real-time, reach out to us at


About the Author

Carson Long

Carson Long is a Technical Writer at MessageGears with an extensive background in writing and instructional design. He uses his knowledge to create streamlined technical content and instructional documentation. In his spare time, he is an aspiring author and an active musician who is always striving to create something new.