Menu
 

Anonymous Invite Emails

Heads up: this is an advanced-level feature in Customer.io, and it’s a little tricky to work with. 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. In this case, “anonymous” means that it’s not associated with a user 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

One disadvantage of anonymous events is that they’re not visible in your activity logs, or in the email composer. This makes it tricky to set up anonymous event triggered campaigns. This is why we recommend using customer-specific events to send invitations wherever possible.

If you have to use an anonymous event, you can get your campaign ready using drafts. Once everything’s good to go, you can send the drafts and set the email to “automatic”.

Design the event

In this example, 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:

{
    first_name: "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

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/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

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

Note: because anonymous events don’t show up in your activity logs, you won’t be able to see this event anywhere in the Customer.io UI.

Set up your campaign

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

Event triggered campaign setup

As noted above, anonymous events don’t show up in the user interface. But the campaign will still work, as long as you remember to set the recipient field in your event data.

Add your email

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

Campaign workflow showing anonymous invitation email

Customize your email content!

You can use all the attributes you send as event data here. Again, because anonymous events aren’t available in the UI, you can’t preview Liquid. But you can still write the email template with Liquid code, 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!