Christopher Orr

Useful examples of Snippets on Customer.io

Here’s a quick example of how I use the Snippets feature on Customer.io Journeys. Snippets are handy dynamic shortcuts you can use in your messages: whether in an email subject or body, in a push notification, a Slack message, or anywhere else.

Snippets are powerful because they can use Liquid templating logic, can access the profile attributes for each of your customers, and because you can easily use them anywhere just by adding something like {{snippets.name}}.

Show the correct emoji for the customer’s location

Sometimes, a tiny touch — something as small as the right emoji — can make a product feel more intentional and human. For Planet Wild, where everything we do is very much connected to our planet, we often use the Earth emoji in email subject lines.

As I was setting up one such email on Customer.io, I had a thought… 🤔

When contacting our community members, we should include the appropriate Earth emoji for where they live! Just like I’ve personalised this one for where you are: 🌎

I was already making sure that every profile in Customer.io has the timezone attribute defined, and so that’s what I used to create this earth snippet:

{% capture emoji %}
{% if customer.timezone contains 'America/' %}
🌎
{% elsif customer.timezone contains 'Asia/'
      or customer.timezone contains 'Australia/'
      or customer.timezone contains 'Indian/'
      or customer.timezone contains 'Pacific/' %}
🌏
{% else %}
🌍
{% endif %}
{% endcapture %}{{ emoji | strip }}

I was then able to write an email subject line like this, which shows the correct emoji for each recipient when sent:

Welcome to Planet Wild! {{snippets.earth}}

How this works

Customer.io supports time zone formats that include the standardised “tzdb” IDs, which look like Europe/Berlin, Pacific/Auckland, or America/Sao_Paulo.

The full set of time zone database identifiers arranges the globe into ten regions:

$ curl -s 'https://raw.githubusercontent.com/vvo/tzdb/refs/tags/v6.149.0/raw-time-zones.json' \
    | jq -r '.[].name' | cut -d/ -f1 | sort | uniq
Africa
America
Antarctica
Arctic
Asia
Atlantic
Australia
Europe
Indian
Pacific

My earth snippet tries to select the best emoji based on the timezone’s region, falling back to the globe emoji for Europe in case of other regions, or if the Customer.io profile is missing a timezone attribute for some reason.

I’m using capture to place the value into a variable caled emoji, and then outputting it with strip at the end, so that the emoji is shown without whitespace on either side. Without this, all the spaces and newlines within this snippet would be part of the output.

Enjoy!