Importing old data into Customer.io

Once you’ve had a chance to see Customer.io work, the next thing you might want to do is back-fill your historical data. Here are a couple of options.

Backfilling People

1. Advanced: Write a script

If you’re a developer, you may want to write a quick script to loop through all of the people in your database and add them to Customer.io. While this creates a lot of API requests, it’s fine to do and won’t overload our system if you follow the API guidelines.

Note, that your API calls may not be processed in the order you send them. If you will be sending multiple identify() calls per user and chronology of the attribute updates is important to you, you will need to send a _timestamp value as discussed in our documentation on User Attributes.

Libraries

Choose a library for your language of choice

2. Easier: Upload a CSV file

Customer.io shines best when we have access to a stream of real-time data about your users so we’d like to see if there’s anything we can do to help you get this type of data flowing directly into your account.

However, in cases where you need to backfill historical data into your new account or you want to complete one-time imports, you are able to upload a CSV file of users.

For more information, check out: Uploading People via CSV

Advanced: Backfilling Events

You can optionally add historical event data by adding a timestamp.

Please be aware that backfilling event data may trigger campaigns or messages, if those events are used as triggers!

cURL:

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

cURL (JSON):

curl -i https://track.customer.io/api/v1/customers/5/events \
  -X POST \
  -u YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE \
  -H 'Content-Type:application/json' \
  -d '{"name":"purchased","timestamp":1359389415, data":{"price":23.45}}'

If you want to also use the event timestamp to customize your emails, you can add an additional attribute to the data hash like this:

curl -i https://track.customer.io/api/v1/customers/5/events \
  -X POST \
  -u YOUR-SITE-ID-HERE:YOUR-SECRET-API-KEY-HERE \
  -H 'Content-Type:application/json' \
  -d '{"name":"purchased","timestamp":1359389415, data":{"price":23.45, "timestamp":1359389415}}'

If you need help on any of these issues, please get in touch.