Written by Drip

Global Variables with Snippets in Drip

How to create massively dynamic content and hundreds of unique emails with minimal code and time.

To start with, if you don’t know what Drip is – Drip (drip.com) – an awesome tool for collecting data, sending emails, creating automation workflows. Drip uses the Shopify syntax Liquid.

This trick came about because I needed a way to create over 100 unique emails in pretty much zero time.

What is this and why is this useful?

Drip introduced snippets last year, or maybe it was early this year. 2 weeks ago I discovered you could do something very nifty with snippets.

You can set variables inside of Drip snippets, and use those variables outside of the snippet – I call them global variables.

If you use this trick, you can:

  • Create massively dynamic content and hundreds of unique outgoing emails with minimal liquid code in your emails.
  • Have a massive list of variables inside of a snippet, and set those variables with liquid conditions based on the values of a subscribers custom fields and tags.
  • Use the variables as many emails are you like, and easily update them from the one place.

How to do this:

1 – Setup a new snippet. For my first one, I called it project_variables

2 – Set the variables, inside of the snippet like this:

{% if subscriber.next_event = 'project-sydney' %}
  {% assign city_name = 'Sydney' %}
  {% assign event_location = 'Sydney Harbour Bridge' %}
  {% assign event_date = '2018-12-28' %}
{% elsif subscriber.next_event = 'project-brisbane' %}
  {% assign city_name = 'Brisbane' %}
  {% assign event_location = 'Southbank' %}
  {% assign event_date = '2018-12-29' %}
{% endif %}

3 – Minimise the snippet code, strip out line breaks and spaces between liquid

 4 – Use the variables in your email:

{{ snippets.project_variables }}We'll see you in {{event_city}} this {{ event_date | date: "%A" }}

That is it. Pretty simple, powerful, useful.

 As of December 2018, this trick only works in Broadcasts and Campaign emails. 

Last modified: December 12, 2018