Events are actions your users do 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?
_cio.track('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 create segments out of them in our app. You can create segments based on actions users have or have not done. You can also set a time frame for the action – e.g., “have not created_project in 30 days”, or “have invited_friend since signing up”.
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 in the format “time since the epoch”. 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 did eventX in the last 30 days”.
Important things to know:
We recommend not to put spaces in your event names:
'event name' Bad. 'event_name' Good. 'eventName' Good.
Ensure that the event name used in
_cio.track('event_name') and the event name used to create a segment are the same.