Importing customer data
When you first integrate with Talon.One, ensure you import information about your existing customers to maximize the use of targeted campaigns immediately.
Customer data consists of two entities:
- Customer profiles
- Customer sessions, which represent orders.
- You can only import customer profiles programmatically using the Update customer profile and Update multiple customer profiles endpoints.
- You can only import your customers' historical sales data programmatically using the Update customer session endpoint.
Prerequisites
- You have created an Application in Talon.One.
- You have created an Integration API key.
Step 1: Importing customer profiles
In Talon.One, customer profile entities represent the data related to your customers.
This example shows how to import customer profile data using the Update customer profile endpoint both directly and via an SDK.
- curl
- Ruby
curl --request PUT 'https://example.talon.one/v2/customer_profiles/mysessionid' \
--header 'Authorization: ApiKey-v1 my_api_key' \
--header 'Content-Type: application/json' \
--data-raw '{
"attributes": {
"Name": "John doe",
"Email": "john.doe@example.com",
"SignupDate": "2012-07-09T19:22:09.1440844Z",
"Phone": "202-555-0113"
},
"responseContent": [
"customerProfile"
]
}'
Using the Ruby SDK, you can use the following style of loop:
talon = TalonOne::Integration::Client.new
User.each do |user|
talon.update_customer_profile_v2 "user-#{user.id}", {
:attributes => {
"Name" => user.name,
"Email" => user.email,
"SignupDate" => user.created_at,
"Phone" => user.phone_number,
}
}
end
- Mapping your customer data to profile attributes depends on your Application.
- You can define your own profile attributes for any data you need for your targeted campaigns.
Step 2: Importing past customer orders
You can import the historical sales data of your customers to use it in your campaigns. In Talon.One, past customer orders are considered closed sessions.
Similar to importing customer profiles, you can loop through these past orders and create a closed session for each order using the Update customer session endpoint.
- curl
- Ruby
Values between angle brackets mean they come from your order management system.
curl --request PUT 'https://example.talon.one/v2/customer_sessions/mysessionid' \
--header 'Authorization: ApiKey-v1 my_api_key' \
--header 'Content-Type: application/json' \
--data-raw '{
"customerSession": {
"profileId": "<somecustomerid>",
"state": "closed",
"total": "<ordertotal>",
"attributes": {
"BillingName": "<billinginfo>",
"ShippingCost": "<shippingcost>"
}
},
"responseContent": [
"customerSession",
"customerProfile"
]
}'
Using the Ruby SDK, you can use the following style of loop:
Order.where(:state => "closed").each do |order|
talon.update_customer_session "order-#{order.id}", {
"profileId" => "user-#{order.user.id}",
"total" => order.total,
"state" => "closed",
"attributes" => {
"BillingName" => order.billing_details.name,
"ShippingCost" => order.shipping_cost,
}
}
- Mapping your order history to session attributes depends on your Application.
- See Attributes for more information on custom attributes and how to use them.
- The
profileId
of a session should match the ID you assigned to the customer profile when you used the Update customer profile endpoint. - The
state
of a session must be set toclosed
for Talon.One to include that order in the total sales calculation for the associated profile.