How do I add dynamic content or custom fields to my messages?

Deliver personalized messages to your users by adding properties stored in people profiles to your Mixpanel messages. You can use any people property in your project to add customization to your email, in-app and push notifications.

Add variables to email and push notifications

To customize your email or push notification with a people property, simply type two curly brackets into your message:

{{

From there, you can select a property to add from the dropdown (closing brackets will automatically be added). The Mixpanel default properties will appear first, but you can start typing the names of other properties as well, and they will appear in the dropdown. If the property does not populate in the dropdown, you can add the variable using the syntax documented below for in-app messages.

Add variables to in-app messages

To get the value of your people properties into your in-app messages, you’ll use a variable. When Mixpanel delivers the message, the variable will be replaced with the value of that property in the user’s people profile:

Variables look like this:

{{ ${property} }}

End user view:

Your last order was January 10! Come back and get 15% off.

Your view:

Your last order was {{ ${date of last order} }}! Come back and get 15% off.

Fallback values

If not all your profiles have the same properties, you’ll want to provide a fallback value so that messages for users without a certain property don’t arrive blank or broken:

{{ ${property} | fallback:"default value" }}

For example:

{{ ${date of last order} | fallback:"a long time ago" }}

If the person doesn’t have a date of last order property value, their message will look like this:

Your last order was a long time ago! Come back and get 15% off.

Advanced customization - conditional blocks

If fallback values aren’t enough to accomplish the message you want to send, you can use conditional blocks:

{% if ${property} %}
   Will appear if property is present.
{% else %}
   Will appear if property is a absent.
{% endif %}

End user view for people with a preferred office location set:

Come and visit us at our Asheville office.

End user view if without a preferred office location set:

You haven't told us your location. Please update your location in your account, and we'll send you to our nearest office.

Your view:

{% if ${Office location} %}
   Come and visit us at our {{ ${Office location} }} office.
{% else %}
   You haven't told us your location. Please update your
   location in your account, and we'll send you to our nearest office.
{% endif %}

If you want a value to appear only if the property exists on the user’s people profile, you can exclude the {%else%} tag from your conditional block. In this example, anyone without a Visit Count property will receive only “Thanks for coming by!”:

Thanks for coming by!
{% if ${Visit Count} %}
    You have visited {{ ${Visit Count} }} times.
{% endif %}

It is important to note that conditional blocks can only show the value of a property itself and cannot be configured to send different messages based on that value.

For example, it is not possible to use conditional blocks to send Message A if the value of the "Visit count" property is greater than 10 and Message B if the value of the "'Visit count" property is less than 10. Instead, If this is your goal, you should set up messages with different targeting as opposed to trying to use logic within a single message.