Anonymous Invite Emails

Heads up: If you want to allow people in your database to invite their friends, please try out our “Invite Emails” recipe instead of this one.

Introduction

Do you need to send emails to people who aren’t yet in your Customer.io database? You can do this using anonymous events and an event-triggered campaign. This will allow you to send emails like:

From: Jo at CoolApp <jo@coolapp.com>
To: alex@example.com
Subject: Exclusive invitation: CoolApp beta, just launched!

Hey Alex,

As a registered OldApp beta tester, we’d like to invite you to try out our new CoolApp! Click here to get started.

The CoolApp Team

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

For this example, you’ll want to send an anonymous event. “Anonymous” means that it’s not associated with a person already in your system, so you’ll need to include all the necessary information in the event itself.

Most importantly, the email address must be specified in the recipient field of the event. You’ll see more about this below.

Set up your campaign

We still recommend using customer-specific events to send invitations wherever possible. But if you have to use an anonymous event, you can get your campaign ready using drafts, for QA purposes. Once everything’s good to go, you can send the drafts and set the messages to Send Automatically.

Design the event

For this campaign, let’s assume that you want to send an invite email to someone not yet in your system about a new app beta test.

To do that, we’ll use an event called beta_test_invite. Send along all the data you need to customize your email in the event data, like this:

The most important thing to remember is to set the recipient field in your event data. The campaign will not work without it.
{
  "name":"beta_test_invite",
    "data": {
      "firstname": "Alex", 
      "source":"oldApp", 
      "recipient":"alex@example.com"
    }
}

Send the event with cURL

To send the event, you’ll want to hit the following endpoint:

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

To test, you can send a single 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/events \
-X POST \
-u YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE \
-d name=beta_test_invite \
-d data[first_name]=CUSTOMER-FIRST-NAME-HERE \
-d data[recipient]=RECIPIENT-EMAIL-HERE

However, in your integration, you may be sending us this data via our API. We have more in-depth API information here, should you need it.

Check the event

The above event will show up in your Activity Logs, like this:

Anonymous event

Set up your campaign

Create an event triggered campaign, with beta_test_invite as the event trigger:

Event triggered campaign setup

Add your email and its content

In your workflow, create the email that you’d like to send:

Campaign workflow showing anonymous invitation email

Then, when writing your message, you can use all the attributes you send as event data here, like this:

Composer with email content

Note: in the above example, we set the "To" field to {{event.recipient}}. This event data attribute is required for your campaign to trigger and the email to send, and setting it here makes it clear that's where the email will go. You can't use any other event data here—it has to be recipient.

Try it out with drafts

Once you’ve set up your content, leave the email set to “Queue Draft” and start your campaign. Now, send us a test event using curl as above. That command again:

curl -i https://track.customer.io/api/v1/events \
-X POST \
-u YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE \
-d name=beta_test_invite \
-d data[first_name]=Alex \
-d data[source]=OldApp \
-d data[recipient]=alex@example.com

If that worked, check out your campaign’s drafts page to see your new draft:

Drafts listing with one draft

And take a look at the draft to make sure it works as you expected:

Draft detail

If not, edit your email and check the draft again. Don’t forget to try all of your event data permutations to make sure the email template works.

Once you’re ready, just flip your email setting to “Send Automatically”, and send all your drafts. All done!

Wrap Up

Anonymous events are a little tricky to work with, but a great way to bring new users into your application. We do recommend using normal events to invite friends where possible, as it’s much easier to get started.

If you have any problems or questions about this topic, please get in touch and we’d be happy to help!