It’s nice when something has a personal touch. Society may have discarded the ritual of the hand-written letter, but when you send an email to your supporters or customers, you have one brief, shining moment to make them feel special. Frankly, your supporters are expecting email personalization.

That’s where Twig comes in.

Twig is a templating language built into the BSD Tools that gives you a powerful, fast way to do advanced personalization in a snap. Our clients use Twig to deliver high-impact, personalized content to thousands, even millions, of people — without having to go to the trouble of building several different email segments for every send.

So that’s one nice thing about Twig. The other one? It’s replicable! In that spirit, here are six tips for personalizing your content on the BSD Tools using simple Twig code — just copy and paste these, change any variables you want (don’t worry, we’ll point them out), and get cracking.

1. Better fallback for personalization

Never again does your email salutation have to say “Dear Friend.”

Or: “We’re writing to you today, Friend, because we need your help.”

In fact, personalization using Twig can look like whatever you need it to look like!

You can use if-then statements to show two completely different messages to people whose first names you have and those you don’t:

{% if cons.firstname %}Dear {{ cons.firstname }},
{% else %}
Hello --
{% endif %}

Or you can have personalization without fallback:

We're writing to you{% if cons.firstname %}, {{ cons.firstname }},{% endif %} because we need your help

 

And of course, if you want old-school fallback, that’s easy, too. No defaults here, though; the fallback can say whatever you want!

Dear {{ cons.firstname | default("so-and-so") }},

 

Finally, you can use similar tactics with other personalization tags:

Does {% if cons.lastname %}the {{ cons.lastname }} family{% else %}your family{% endif %} have an emergency plan?

2. Donation asks based on giving history

It’s a tale as old as time, or at least since the first fundraiser dropped an ask letter in the mail: We ask donors for money based on their giving history. It’s just what we do, and Twig gives you a ton of control you have over the terms of this ask.

Let’s say you want to ask for 75% of a donor’s highest previous contribution, but cap the ask amounts between $3 and $200. And you want to make sure you’re asking for a round number ($38, not $37.50). Well …

{% set max_ask = 200 %}
{% set min_ask = 3 %}
{% set factor = 0.75 %}
{% set ask = min(max_ask, max(min_ask, factor * hpc_raw)) | round %}

Can you give  ask }} today?

Using this code, non-donors will get asked for $3. Someone who’s given you $500 will be asked for $200. Someone who’s given $100 will be asked for $75. And of course, you can change any of the three variables here based on your needs!

Using similar code, you can ask people for a monthly gift based on, e.g., 10% of their highest previous contribution — once again capping the amounts, this time between $5 and $50:

{% set max_ask = 50 %}

{% set min_ask = 5 %}

{% set ask = min(max_ask, max(min_ask, hpc_raw/10 )) | round %}

Will you make your monthly gift of  ask }} today?

What if you wanted to ask someone for 75% of their SECOND highest previous contribution? Yes, you can do that — with fallback to make sure that people who have only given once, or those who have never given at all, still see a normal ask:

{% set amts = column(contribution.contributions, 'transaction_amt') | sort | reverse %} 

{% set max_ask = 200 %}

{% set min_ask = 3 %}

{% set ask = amts[1] ?: amts[0] | default(min_ask) %}

{% set ask = min(max(min_ask, ask * 0.75), max_ask) | round %}

Will you donate  ask }} today?

3. More fun with donor data!

What if you don’t want to ask donors for money at all — but you do want to ask non-donors to give a little something? Easy peasy:

{% if hpc_raw > 0 %}
You're so amazing for being a part of this team. Thank you so much for your gift!
{% else %}
Can you chip in $3 and be a part of this?
{% endif %}

 

Or what if you want to show donors their average gift, while still having fallback for non-donors?

{% set amts = column(contribution.contributions, 'transaction_amt') | sort | reverse %}
{% if hpc_raw > 0 %}
Your average gift is  (sum(amts)/amts|length) | round }}!
{% else %}
You still haven't given!
{% endif %}

 

(This one’s really nice, but be extra careful to only show it to donors or to have fallback, as in the above example! Since non-donors have never made a gift, trying to calculate their average contribution results in dividing by zero, and you’ll get an error message.)

4. Supporter records

In addition to customizing ask amounts or donor-specific content, Twig lets you create just about any kind of supporter record email you can imagine.

Want to show a donor the date and amount of their very first contribution? Use this:

Your first gift was on {{ contribution.contributions | sort_by("transaction_dt") | first.transaction_dt | date("F j, Y") }}!

You gave  contribution.contributions | sort_by("transaction_dt") | first.transaction_amt | round }}.

 

Similarly, here’s code for the date of someone’s most recent gift:

Your most recent gift was on {{ contribution.contributions | sort_by("transaction_dt") | last.transaction_dt | date("F j, Y")}}!

You gave  contribution.contributions | sort_by("transaction_dt") | last.transaction_amt | round }}.

 

What if you wanted to list every contribution a supporter ever made? It’d look like this:

Your gifts:<br /><br />

{% if hpc_raw > 0%}
{% for contrib in contribution.contributions %}
{{ contrib.transaction_dt | date("F j, Y") }}:
 contrib.transaction_amt | round }}<br />
{% endfor %}
{% else %}
You’ve never given!
{% endif %}

If you wanted to exclude recurring gifts, just make a small tweak:

Your gifts:<br /><br />

{% if hpc_raw > 0%}
{% for contrib in contribution.contributions | where({"is_recurring":0}) %}
{{ contrib.transaction_dt | date("F j, Y") }}:
 contrib.transaction_amt | round }}<br />
{% endfor %}
{% else %}
You’ve never given!
{% endif %}

You can build on this framework to do just about anything. Show a donor all their 2017 gifts! Or show special content to donors who gave on Giving Tuesday! List every contribution over $100 to thank those big spenders! It’s all possible with Twig, and we’re happy to help walk you through it.

5. Content by constituent group

Supporter records aren’t just for donors. Using Twig, you can show content exclusively to a supporter in any given constituent group — all you need is the constituent group ID, which is shown in the Tools on the Manage Constituent Groups page under the ‘Group ID’ header.

Let’s say you have a group of people who have called their legislative offices on a given topic, with a group ID of 1; another group that’s signed a petition, with a group ID of 2; and another group that hasn’t taken action. You can show members in each group a call to action that helps move them up to the next rung on your ladder of engagement:

{% if cons.inConsGroup(1) %}
    Thank you for calling your members of Congress -- now, will you sign up to volunteer at one of our town halls?
{% elseif cons.inConsGroup(2) %}
    Thank you for signing our petition -- now, can you take the next step and call your members of Congress?
{% else  %}
    According to our records, you haven't taken action yet -- sign our petition today!
{% endif %}

6. Geographic targeting

There’s no need to make 50+ segments of an email anymore. Using if-then statements, you can target constituents in any given state:

{% if cons_addr.state_abbr == "NY" %}

Say something nice about New York!

{% elseif cons_addr.state_abbr == "MA" %}

And Massachusetts!

{% elseif cons_addr.state_abbr == "CA" %}

And California!

{% else %}

This is the content that would go to everyone else, including constituents without addresses.

{% endif %}


I hope these examples are useful — we’ve designed them so you can copy and paste them into your campaigns right now.

But as you can probably tell, they’re just some of the ways you can really make your content feel personalized for your supporters! Dig into more documentation here — and get in touch with us if you want help taking your email program to the next level.

 

2018 Fundraising Insights Report | Blue State Digital