Anonymous Events

Start logging events before people sign up or log into your site, app, or service. When people sign up or log in, you can associate those events with people. Anonymous events help you do things like personalize your onboarding campaigns based on things people did before they signed up. For example, if a customer viewed a pricing plan before signing up for a trial, your onboarding campaign might cover features relevant to the plan they viewed.

An anonymous event is an event associated with a person you don’t recognize. The event bears an anonymous_id—a value representing the unknown person, like a cookie. We store these events for up to 30 days.

The Anonymous event merge feature lets you associate these events with a person after you identify them. You can enable anonymous event merging in your workspace settings.

  • If you use the javascript snippet: we automatically log anonymous events and associate them with people you identify.
  • If you use the API: When you log anonymous events, you’ll set an anonymous_id on the event. When you identify people, you can set a corresponding anonymous_id attribute. We associate events with a person if the anonymous_id attribute and event values match.
Flow to associate anonymous events with people
Flow to associate anonymous events with people

Turn on anonymous event merging

 Anonymous event merging is on by default for new workspaces

If you created your workspace before July 2021, you must enable Anonymous event merging. Otherwise, anonymous events are not associated with people you identify.

Anonymous event merging is the act of associating anonymous events—events with an anonymous_id—with a person. When you assign an anonymous_id attribute to a person, any anonymous events with that same ID are associated with the person.

  1. Go to Settings > Workspace Settings
  2. Scroll down to Anonymous event merge and click Settings.
    Find anonymous event merge under workspace settings
    Find anonymous event merge under workspace settings
  3. Turn on the Merge anonymous events to identified profiles setting.
  4. Set up an integration that sends events to Customer.io:

Now, any events with an anonymous_id are merged with people bearing the same anonymous_id attribute.

Send anonymous events using the Javascript snippet

Using the Javascript snippet, you can send anonymous events with _cio.track. If you’ve enabled Anonymous event merging, the javascript snippet automatically associates events (that occurred in the past 30 days) with people when you identify them.

So, for example, if a person adds items to their cart before they log in, the snippet automatically associates those events with a person when they log in.

<script type="text/javascript">
    _cio.track("addedToCart", { product: "cool-shoes" });
    _cio.identify({
        id: 'YOUR_USER_ID_HERE',
    });
</script>

Send anonymous events using the API

If you send events to us using the API, you must set anonymous_id in the payload of an anonymous event call. When you identify a person and set their anonymous_id attribute to a value matching one or more events, we’ll merge the corresponding anonymous event with the person.

The example event below has an anonymous_id of abc123. Anonymous event IDs must be unique and are not reusable.

{
    "name": "https://example.com/interesting-page",
    "anonymous_id": "abc123",
    "type": "page",
    "data": {
     "first_name": "Person",
    }
}

The example identify call associates the event above with a person.

curl --request PUT \
  --url https://track.customer.io/api/v1/customers/{identifier} \
  --header "Authorization: Basic $(echo -n site_id:api_key | base64)" \
  --header 'content-type: application/json' \
  --data '{"email":"user@example.com","anonymous_id":"abc123"}'

Associate anonymous events with a person

If you send events and identify people using our API, you must set a person’s anonymous_id attribute to associate events with them. Any anonymous events with the same anonymous_id are automatically associated with the person bearing the corresponding anonymous_id attribute. If the event timestamp is within 72 hours of the present time, an associated event can trigger a campaign.

For example, if you set an anonymous ID of abc123 on a person identified by the email address person@example.com, we associate any events with an anonymous_id of abc123 with that person.

curl --request PUT \
  --url https://track.customer.io/api/v1/customers/{identifier} \
  --header "Authorization: Basic $(echo -n site_id:api_key | base64)" \
  --header 'content-type: application/json' \
  --data '{"email":"person@example.com","anonymous_id":"abc123"}'

If a person logs out, clears their cookies, or otherwise does something that makes them anonymous again, they can log additional anonymous events. When that person logs in again, you can set their anonymous ID to a new value to associate them with any events that occurred during their last anonymous session.

Changing a person’s anonymous ID does not remove events that were associated with them under a previous anonymous_id. This lets you associate events with a person as they log out and back in again, or across other session ending and beginning events.

Flow to associate anonymous events with people
Flow to associate anonymous events with people

Anonymous event retention and campaign triggers

Customer.io retains anonymous events for 30 days. These events don’t do anything—they cannot trigger campaigns or segment membership—until they are associated with a person. They appear in the activity log in the Anonymous tab, but they’re otherwise unusable until you associate them with a person by anonymous_id.

When an anonymous event is associated with a person, it can trigger a campaign if it occurred within the past 72 hours.

Third-party support for anonymous events

The following third-parties support anonymous events:

  • Segment (Device mode only). We requested that Segment add support for Cloud mode in July 2021, but it may take months. If you want an accelerated timeline, email friends@segment.com.

To request support for anonymous events from other third-party platforms, email the third party directly and CC product@customer.io.

Anonymous events vs invite events

An invite event is very similar to an anonymous event: it uses the same API endpoint as anonymous events, but it contains a data.recipient field and does not contain an anonymous_id. The recipient contains the email address of someone that you want to send a message to—typically an “invite”, hence “invite event”. Here’s an example payload for an invite event.

{
    "name": "https://example.com/invite-me",
    "type": "page",
    "data": {
        "recipient": "person@example.com",
        "first_name": "Person",
    }
}

Invite events can trigger message campaigns to people who aren’t in your workspace. However, before you consider using events this way, we encourage you to consider transactional messaging—in which a person implicitly requests an email, we identify a person, and then send them a message—or otherwise identifying a person by email first and then triggering a campaign.

Identifying a person provides a way for you to track a person’s preferences (both using the unsubscribed attribute and other attributes). It provides a way to retain information about the person you send messages to, and to track the outcome of your invite—something that you cannot do if you use invite events to send messages directly to a recipient.

Anonymous events in the Activity log

The activity log shows Identified and Anonymous events. Identified events are events associated with a person in your workspace. Anonymous events are associated with an unknown person. While we capture anonymous events, these events don’t do anything until you associate (or merge) them with a person.

When events are merged to a person’s profile, they become “identified” and appear in the Identified tab. Events with a icon next to the person, were previously anonymous events that are now associated with a person.

identified events
identified events
Copied to clipboard!