Skip to main content

How can I compare a donor's year over year donation total in email?

Official response from

Using Liquid variables in email, you can total all of a donor's donations for a given year. If they have given less this year than last, you might use this as a personalized way to encourage them to contribute more this year.

To do this, you need to create variables that will store the total donation amount for this year and last year. This guide will use 2018 and 2017, but you can replace the years in the code block below to do this for future years.

{% assign 2017donations = '0' %}{% assign 2018donations = '0' %}{% for donation in recipient.donations %}{% assign donation_year = donation.succeeded_at | date: '%Y' %}{% assign donation_amount = donation.amount_in_cents | divided_by: 100 %}{% if donation_year == '2017' %}{% assign 2017donations = 2017donations | plus: donation_amount %}{% elsif donation_year == '2018' %}{% assign 2018donations = 2018donations | plus: donation_amount %}{% endif %}{% endfor %}

Copy and paste this code block with no line breaks at the top of your email blast.

code_block.png

If you did everything correctly, it shouldn't display anything in the email preview.

email_salutation.png

The above code scans through all of a donor's donations, totals all of the 2017 donations into a {{2017donations}} variable, and totals all of the 2018 donations into a {{2018donations}} variable.

You can now display a donor's giving history in your email and make a customized ask based on which year has more total donations.

wysiwyg.png

In this example, I show the donor what they gave each year, and if they gave more last year, I ask them to donate (you could combine this with my guide to prefilling an ask amount to prefill the donation form with the exact amount they need to match last year's total). If they've already given more this year, I ask them to recruit friends to donate.

email_output.png

Always send test emails to confirm that your Liquid works.

Share this post

Showing 4 reactions

How would you tag this suggestion?
Please check your e-mail for a link to activate your account.