Skip to content

Pulling user profile data

This page covers how to pull user profiles into your Connected Content calls and best practices involving Liquid templating.

Prerequisites

If a Connected Content response contains user profile fields (within a Liquid personalization tag), these values must be defined earlier in the message with Liquid, before the Connected Content call in order to render the Liquid passback properly. Similarly, the :rerender flag must be included in the request. Note that the :rerender flag is only one level deep, meaning that it will not apply to any nested Connected Content tags.

Liquid templating in Connected Content calls

For personalization, Braze pulls user profile fields before passing that field to Liquid—so if the response from Connected Content has user profile fields, it must be defined beforehand.

For example, if this were the Connected Content call:

1
2
Hi ${first_name},
{% connected_content https://examplewebsite.com :rerender %}

The Connected Content response is Your language is ${language}. The content displayed in this example is Hi Jon, your language is.

The language itself won’t be templated. This is because Braze needs to know what fields to retrieve from the user before we make the Connected Content call.

To render the Liquid passback properly, you must include the ${language} tag anywhere in the request, as shown in the following code snippet. The Liquid preprocessor will know to grab the “language” attribute from the user to have it ready for templating the response.

1
"Hi ${first_name}, {% connected_content https://examplewebsite.com?language=${language} :rerender %}

Best practices

Use json_escape with Liquid tags that could break the JSON format

When using :rerender, add the json_escape filter to any Liquid tag that could potentially break the JSON format. If your Liquid tags contain characters that break the JSON format, the entire Connected Content response will be interpreted as text and be templated into the message, and none of the variables will be saved.

For example, if the message event property in the example below contains characters that could break the JSON format, add the json_escape filter like in this example:

1
2
3
[{
"message":"{{event_properties.${message} | json_escape}}"
}]
HOW HELPFUL WAS THIS PAGE?
New Stuff!