Events

Events


Events are actions people perform in your app. Events can be things like button clicks, scrolling to the bottom of a page, or even things that happen behind the scenes, like a successful credit card charge. Once you send us event data, you can segment your users based on events they have or have not done in your app.

How do I send you event data?

First, ensure you've added our Javascript snippet to every page where you'd like to send an event.

Then, call _cio.track('your_event_name'); whenever your users take an important action you'd like us to track. Alternatively, you can send us event data through our REST API.

Our tracking function works based on the current browser session, so there is no need to tell us which user to associate the event with, as long as you have done the basic integration.

How do I create event segments in Customer.io?

Once you're sending us these events, you can then build data-driven segments from them based on actions users have or have not done. Make sure that the event name used in _cio.track('your_event_name') and the event name used to create a segment are the same.

You can also set a time frame for the action — e.g., "have not created_project in 30 days", or "have invited_friend in the last 14 days".

Here's an example without a timeframe:

image.png

And if you'd like to add the timeframe, click Refine, and adjust the time inputs:

image.png

Can I let you know about old events?

Yes. There's an optional event attribute named timestamp. By default, we'll use the time we received the event, but you can override this when backfilling data, or if you want to have a consistent timestamp across services.

You should send the timestamp as a Unix timestamp (seconds since the epoch).

Please be aware that backfilling event data may trigger campaigns or messages, if those events are used as triggers!
Also note that we only show activity for the last 30 days in Customer.io. This means events that are older than 30 days will be logged for use in segmentation (e.g., "event 'made_purchase' has been performed at least once") but they will not appear in your activity logs.

Here's an example of how to send this data using curl to the REST API.

curl -i https://track.customer.io/api/v1/customers/5/events \
   -u YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE \
   -d name=purchased \
   -d data[price]=23.45
   -d timestamp=1359389415

Each event can have a timestamp and we'll use that timestamp when matching segments like: "users who performed event X in the last 30 days".

Tracking push notification opens with events

If you're sending push notifications via Customer.io, you can also track opens by sending us an event when your app detects it was opened as result of a customer tapping a push notification. Send us an event named opened with CIO-Delivery-ID and CIO-Delivery-Token parameters which correspond to the push notification. We have more details in our push developer guide here.

Event Name Format

We recommend not using spaces in your event names and event parameters. For example, instead of sending new sign up, use new_sign_up or newSignUp.

If you're already using spaces and haven't run into any issues, then feel free to keep them as is. The only difference you'll see is that you'll need to use different notion to reference these parameters in your messages:

  • Without spaces: {{ event.sign_up_date }}
  • With spaces: {{ event["sign up date"] }}

Also note that *, +, and | characters are not supported in event names.

Anonymous Events

Events are only attributed to a customer after the user is identified in Customer.io. Unfortunately, we’re currently not able to create anonymous users from anonymous data or able to retroactively associate them to the user after they’ve been created.

This is something we’re actively working on improving, but no timeline has been established yet for when it will be available.

Was this article helpful?