Skip to main content
All CollectionsBrazeBraze - Broadcast Message Experiments with Dynamic Optimisation
Braze - Email - Broadcast Dynamic Optimisation - Message Preparation
Braze - Email - Broadcast Dynamic Optimisation - Message Preparation

Prepare your Braze broadcast email message with Dynamic Optimisation code snippets

Updated over a week ago

With your reusable Content Block created, we can move on to the message.

You'll be using another Connected Content code snippet to reference the Content Block you created.

While the Content Block is reusable, you will need to make important changes to the code snippet in your message for each new Jacquard experiment you run.

If you're planning to save the code snippet we're about to review for reuse, ensure you remember to update each requisite piece as instructed below.

Written walkthrough

1. Paste the code snippet into the part of the email you're optimising

Each time you are going to deploy an email with a unique Jacquard experiment, you'll need to paste the following code snippet into the are of the email you're planning to optimise.

{% assign phraseeExperimentId = '<campaign_id>' %}
{{content_blocks.${CONTENT_BLOCK_NAME}}}{% comment %}{% endcomment %}{% if {{variants.variant_text}} == blank or {{variants.variant_text}} == null %}
PASTE YOUR HUMAN CONTROL HERE
{% else %}
{{variants.variant_text}}
{% endif %}

In this example, we're optimising our subject line as so have pasted the code snippet into the Subject field of our Braze email campaign.

2. Replace the Content Block name placeholder with your Content Block's name

You'll need to paste the name of reusable Content Block you created earlier over the CONTENT_BLOCK_NAME placeholder. When you do, ensure you leave the open and close brackets intact.

You'll notice in our example our block is named phraseeContent.

3. Replace the campaign ID placeholder with your experiment ID

Each Jacquard experiment has a unique experiment ID. You'll need to paste your experiment's unique ID over the <campaign_id> placeholder in the code snippet.

If you need help locating your experiment ID, see our ID documentation.

When pasting your experiment ID, ensure you leave the apostrophes surrounding the placeholder intact, but remove the angle brackets, as in the example below:

4. Replace the fallback placeholder with your human control language

The code snippet has fallback logic in place in the event Braze encounters problems processing the snippet.

You'll need to replace the PASTE YOUR HUMAN CONTROL HERE placeholder text with your actual human control language from your Jacquard experiment:

5. Paste the body code snippet into the HTML Email Body

Jacquard uses a tracking pixel to capture open data for your experiment. You'll need to paste the following code snippet into the HTML Email Body of your Braze email campaign:

{% assign phraseeExperimentId = '<campaign_id>' %}{{content_blocks.${CONTENT_BLOCK_NAME}}}{% comment %}{% endcomment %}<img src="{{variants.statistics_url}}" width="1px" height="1px">

We recommend pasting the snippet for the HTML body just below where the preheader renders in your email. This location can vary depending on how your template was developed, so check with your email developer if you need additional guidance.

6. Replace the placeholders with your Content Block name and experiment ID

Just as we did for the language code snippet, we'll need to replace the CONTENT_BLOCK_NAME and <campaign_id> placeholders with your actual Content Block name and experiment ID.

It should look something like this when complete:

7. Add personalisation tags to the language code snippet (optional)

If your Jacquard language variants contain any personalisation tags, please expand the Personalisation section below for further instructions.

Personalisation

Personalisation includes anything from first name to product. It is any field Braze will need to process to plug in information unique to a user.

You'll need to add your personalisation tags them to your subject line code snippet in between the {% comment %} and {% endcomment %} tag.

If you don't include the personalisation tags within the comment tags, Braze won't process them properly and they'll be rendered as literal text within your subject line. This would result in something like Hi, {{$first_name}} showing up in a subscriber's inbox.

Our example below shows how a code snippet might be configured with Braze's default first name personalisation field:

{% assign phraseeExperimentId = 'PhAK33xPer1m3nT1d4d0cUM3NtAt1oN' %}{{content_blocks.${phraseeContent}}}{% comment %} {{${first_name}}} {% endcomment %}{% if {{variants.variant_text}} == blank or {{variants.variant_text}} == null %}
Something special just for you...
{% else %}
{{variants.variant_text}}
{% endif %}

Note the placement of the {{${first_name}}} tag between the comment tags.

If you require multiple personalisation tags, you can simply add them between the {% comment %} and {% endcomment %} tag with a space between them, as in:

{% comment %} {{${first_name}}} {{${last_name}}} {% endcomment %}

If your personalisation tag uses Liquid Filters to modify the output, then these filters need to be assigned along with the tag to a new variable. It's this variable that would then appear in your Jacquard language.

For example, if you want to capitalise the first_name field with {{${first_name} | capitalize}}, then you must first assign this to a new variable before calling the Jacquard Content Block:

{% assign capitalizedFirstName = {{${first_name} | capitalize}} %}
{% assign phraseeExperimentId = 'PhAK33xPer1m3nT1d4d0cUM3NtAt1oN' %}{{content_blocks.${phraseeContent}}}{% comment %} {{capitalizedFirstName}} {% endcomment %}{% if {{variants.variant_text}} == blank or {{variants.variant_text}} == null %}
Something special just for you...
{% else %}
{{variants.variant_text}}
{% endif %}

Note how the assign capitalizedFirstName appears before the assign phraseeExperimentId and also how the newly created variable, {{capitalizedFirstName}}, now appears between the comment tags instead of the default personalisation tag.

8. Test your email

Once you've added your code snippets properly to Braze and activated your experiment in Jacquard, you should be able to preview the email and see your subject lines populating dynamically.

In addition to previews, we always recommend as a best practice to do a live deployment to a small, internal test list to ensure everything will function correctly in a live send.

CEPs often render previews differently than live sends, so it is important to test both.

After you've set all of this up for the first time, it's a good idea to save your code snippets somewhere safe so you can simply reuse them in the future by swapping out the experiment ID and human control language.

Once you've verified your code snippets and personalisation tags (if used) are functioning properly, you've completed your minimum email setup.

Continue along the article path for important instructions for deploying your experiment.


Article path

Related articles

Page last reviewed: 10 April 2024

Did this answer your question?