Importing existing customer data
As a tool for making targeted campaigns, Talon.One can only be as powerful as the data you give it. When first setting up your integration, ensure you prefill information about your customers so that your campaigns can make smart decisions immediately.
Importing customer profiles
In Talon.One, the data related to a customer is represented by the customer profile entity.
To update customer profile data, use the Update customer profile endpoint directly or via an SDK.
Example
- curl
- Ruby
Using curl, you can update one profile like follows.
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 "user-#{user.id}", {
:attributes => {
"Name" => user.name,
"Email" => user.email,
"SignupDate" => user.created_at,
"Phone" => user.phone_number,
}
}
end
- The details of how to map your customer data to profile attributes depends on your Application.
- A complete list of built-in attributes can be found in the attribute library reference.
- You can define your own profile attributes for any data you need in your targeting campaigns.
Importing past customer sessions
Importing the historical sales data related to your customers allows you to use this information in your campaigns. Historical orders are considered as closed session in Talon.One. We can create closed sessions with the Update customer session operation.
Similar to profiles, you can loop through these past orders and create a session for each one.
We are dealing with past orders, so we create them as closed
.
Read more about sessions management in Customer sessions
Example
- curl
- Ruby
Using curl, you can update one session like follows. 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 kind 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,
}
}
- Like customer profiles, the mapping of order history to session attributes depends on your Application.
- See Attributes for more information on custom attributes how to use them.
- The
profileId
of a session should match the ID you created when loading customer profiles. - 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.