Written by Code Snippets

Drip: Epic Greeting Snippet

Wouldn’t it be cool if your automated and broadcast emails could greet people like: Good Evening, Good Morning, Merry Christmas, Happy Friday – depending on the subscribers date and time? This snippet does just that.

Happy New Year, peeps!

Last night, a fellow Drip user was looking to make a content snippet that says either “Happy new year” or “Good morning” based on the date, which reminded me of a time based greeting snippet I had sitting in my Drip snippets from a past night of experimenting👨‍🔬. So, I went back and added date and day based greetings.

Find snippet below!

Subscriber time-based greetings snippet:

This greets people based on their local time.

{% assign rightNow = now | in_time_zone: subscriber.time_zone %}{% assign good_morning = "Good morning, name!+++Morning name,+++Having a good morning, name?+++" | split: "+++" %}{% assign good_day = "Hi name,+++Hey name!+++Hello name!+++G'day name!+++Howdy name!+++" | split: "+++" %}{% assign good_night = "Good evening, name,+++ Hi name, hope you had a nice day,+++ Hi name, hope you're having a nice evening! 😊+++" | split: "+++" %}{% assign randomMorning = rightNow | date: "%N" | modulo: good_morning.size %}{% assign randomHello = rightNow | date: "%N" | modulo: good_day.size %}{% assign randomEvening = rightNow | date: "%N" | modulo: good_night.size %}{% assign subname = subscriber.first_name | capitalize %}{% assign the_hour = rightNow | date:"%k" %}{% capture greeting%}{% if subscriber.first_name == blank%}Hi there,{% elsif subscriber.friendly_time_zone == blank %}{{good_day[randomHello]}}{% elsif the_hour < "10" %}{{good_morning[randomMorning]}}{% elsif the_hour >= "10" and the_hour < "17" %}{{good_day[randomHello]}}{% elsif the_hour >= "17" %}{{good_night[randomEvening]}}{% endif %}{% endcapture %} {{greeting | replace: "name", subname }}

The everything snippet:

This one has subscriber time-based greetings, Happy Friday, Christmas, New Year’s day and Happy New Year.

{% assign rightNow = now | in_time_zone: subscriber.time_zone %}{% assign good_morning = "Good morning, name!+++Morning name,+++Having a good morning, name?+++" | split: "+++" %}{% assign good_day = "Hi name,+++Hey name!+++Hello name!+++G'day name!+++Howdy name!+++" | split: "+++" %}{% assign good_night = "Good evening, name,+++ Hi name, hope you had a nice day,+++ Hi name, hope you're having a nice evening! 😊+++" | split: "+++" %}{% assign randomMorning = rightNow | date: "%N" | modulo: good_morning.size %}{% assign randomHello = rightNow | date: "%N" | modulo: good_day.size %}{% assign randomEvening = rightNow | date: "%N" | modulo: good_night.size %}{% assign subname = subscriber.first_name | capitalize %}{% assign the_hour = rightNow | date:"%k" %}{% assign the_day = rightNow | date:"%A" %}{% assign the_date = rightNow | date:"%B%e" %}{% capture greeting%}{% if subscriber.first_name == blank%}Hi there,{% elsif subscriber.friendly_time_zone == blank %}{{good_day[randomHello]}}{% elsif the_date == "January 1"%}Happy New Year, name!{% elsif the_date == "December 25"%}Merry Christmas, name!{% elsif the_day == "Friday" %}Happy Friday, name!{% elsif the_hour < "10" %}{{good_morning[randomMorning]}}{% elsif the_hour >= "10" and the_hour < "17" %}{{good_day[randomHello]}}{% elsif the_hour >= "17" %}{{good_night[randomEvening]}}{% endif %}{% endcapture %} {{greeting | replace: "name", subname }}

Comment below if you need any help with the above!

Another new post: if you’re interested in awesome lead capturing campaigns, check out my post on the Asics competition.

If you would like to see more posts like this, please join my mailing list.