All Collections
Advance Customizations
How to display dynamic content in your emails based on customer tags
How to display dynamic content in your emails based on customer tags

Hide / show discounts or other content based on customer tags

V
Written by Vincent Panepinto
Updated over a week ago

If you would like to customize your notification emails to display variable content based on customer tags from a given order, you can add custom code to the email templates to display or hide discounts, text, images, or other content based on how the customer is tagged in your Shopify admin.

The most common emails this code is applied to are:

  • Order Confirmation

  • Shipping Confirmation

This guide will show you how to display the following variable content based on the customers tag in the given order:

  • Discount Codes

  • Images

  • Text

  • Product Recommendations

​***

Using a common example to illustrate this, let's say you don't want to display discount codes to your customers tagged 'wholesale' but you do want to show a discount code to all of your other customers.

Once you're in the template builder, drag & drop the code component on to the template above the desired location you want the content to dynamically show.

In our example, we’re using the tag ‘wholesale’ but if you have a different tag, you can replace it with your own tag.

​Insert this code into the custom code component (note: this code cannot be seen by customers on their notifications):

{% assign is_filteredOut = false %}
{% for tag in customer.tags %}
{% if tag == 'Wholesale' %}
{% assign is_filteredOut = true %}
{% endif %}
{% endfor %}
{% if is_filteredOut == true %}


>>> Insert content you want to display to customers who are tagged here <<<

For example, if you want to display something to customers who are tagged as "Wholesaler," you can add that component in this section. Using our example above, we will not be displaying anything there to our wholesale customers, so we will leave this section blank.


Immediately after the discount component, drag and drop a second code component and insert this code into the component:

{% else %}


>>> Insert content you want to display to customers who are NOT tagged here <<<
In this example, we are going to show a discount to regular customers who are not wholesalers.

Finally, drag and drop a third custom code component below the variable content you want to include. Insert this code into the component:

```{% endif %}```

This final code block closes off the loop.

***
Here is a video of this process being done:

To make these changes effective, make sure you set the email templates live into Shopify again, and make sure to test an order to see if it's working as intended.

Have fun and feel free to reach out to [email protected] or through the in-app chat if you have any questions!

Did this answer your question?