Invite Emails

Introduction

Does your app allow people to invite friends? If so, you’ll likely want to contact those invited people—but they’re not yet in your Customer.io database. In this recipe, we’ll walk you through setting up a basic invitation email campaign to send messages such as:

Hi Ami,

Jane just invited you to try out an awesome new app!

Sign up here!

Ingredients

  • Basic understanding of Liquid tags
  • A terminal window and basic knowledge of cURL (or a friendly developer)
  • Your site ID and API key

Method

The easiest way to send invite emails is with events. When a user invites someone new, you can send Customer.io an event, which includes data about the invited person. You can then use that data to get in touch with them.

Send the event

In this example, we’ll use an event called invited_friend. This event is associated with one of your existing users. So when Jane invites her friend Ami, her action sends the event but the event contains contact information for Ami. You’ll send that contact information as the event data, like this:

{
    "friend_name": "ami",
    "friend_email": "ami@customer.io"
}

To send the event and associate it with the inviter, you’ll want to hit the following endpoint:

https://track.customer.io/api/v1/customers/CUSTOMER_ID_HERE/events

The CUSTOMER_ID should match the id attribute of the customer sending the invite. So if Jane’s id in Customer.io is 12345, that’s what we would use there.

Send the event with curl

You can send your event to Customer.io by firing up a Terminal and using this code (with your adjustments, of course):

curl -i https://track.customer.io/api/v1/customers/CUSTOMER_ID_HERE/events  \
-X POST \
-u YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE  \
-d name=invited_friend \
-d data[friend_name]=FRIEND_NAME  \
-d data[friend_email]=FRIEND@EMAIL

After that, the event (and its data) will be available in Customer.io, associated with Jane. Here’s what his activity log would look like:

invited_friend event
invited_friend event

We have more in-depth API information here, should you need it.

Set up your campaign

Use your event as the campaign trigger

Now that you have invitee data moving into Customer.io, let’s put it to use! Set up an event triggered campaign, with invited_friend as the trigger:

Invitation campaign - Trigger Event
Invitation campaign - Trigger Event

Put your data to work!

Drag and drop an email into your workflow builder. Then, remember the event attributes we sent as part of invited_friend? This is where we’ll use them. You don’t want to contact the customer who triggered the event, but the invitee email that they sent as part of it.

Click Customize in the To field and use a Liquid tag {{event.friend_email}} to get the invitee’s email:

Invitation email - editor
Invitation email - editor

I’ve also used the tag {{event.friend_name}} to greet them, and added a link. But you can customise this however you like!

Before you save, you can also check out the Preview to make sure all your tags are working as expected.

Invitation email - preview
Invitation email - preview

You’ll notice that I used Jane’s name and a company email (not Jane’s email address) for the sender. I did this to prevent bounces. Yahoo and many other major email providers have DMARC policies in place to protect against email being sent on their behalf from non-verified sources. The only way to resolve this properly is to use a sending address that uses a domain that is verified in your Customer.io account.

Wrap Up

Events and event data are a good way of getting in touch with people not yet in your Customer.io and kicking off new relationships with them! If this approach doesn’t work for you, though, or you need help getting it set up, send us a message!

Copied to clipboard!
  Contents
Is this page helpful?