Skip to main content
Solved

Importing lists as custom profile properties via API PUT request


Forum|alt.badge.img+5

Hi,

New user, currently integrating. I’m importing/maintaining customer profiles via API call - a PUT request to https://a.klaviyo.com/api//v1/person.

The payload is a standard array (this is PHP, btw, using curl, we have a custom ecommerce setup).

This works fine for built-in and custom properties as long as they are simple types, and also $consent seems to be fine just as an array too, ie:

$dataArr = array(    'api_key' => MY_PRIVATE_KEY,    'active' => 1,    'orphan' => 0,    '$city' => $cust->cust_del_town,    '$country' => $this->zone_countries_name_lookup[$cust->cust_del_country_id],    '$phone_number' => $cust->cust_del_telephone,    '$zip' => $cust->cust_del_postcode,    '$last_name' => $cust->cust_del_last_name,    '$first_name' => $cust->cust_del_first_name,    'last_name' => $cust->cust_del_last_name,    'first_name' => $cust->cust_del_first_name,    '$title' => $cust->cust_del_title,    'country_iso2' => $this->zone_countries_code_lookup[$cust->cust_del_country_id],    'is_uk' => ($cust->cust_del_country_id == UK_COUNTRY_ID ? 1 : 0),    'is_row' => ($cust->cust_del_country_id == UK_COUNTRY_ID ? 0 : 1),    'is_ml' => 0,    'hs_cust_id' => $cust->cust_id,    'hs_contact_type' => 'cust_table',    'hs_subscribed_date' => $cust->cust_reg_datetime,    'hs_no_of_orders' => $noOfOrders,    'hs_order_total_gbp' => $cust_lifetime_order_total,    'hs_last_ordered_datetime' => $most_recent_purchase_date,    'hs_marked_as_fraud' => $cust->fraud,    'hs_product_tags_purchased' => $this->listify($product_tags_purchased, 'str'),    'hs_brands_purchased' => $this->listify($brands_purchased, 'str'),    'hs_date_of_last_return' => $date_of_last_return,    'hs_returned_product_ids' => $this->listify($returned_product_ids, 'num'),    'hs_last_shoe_size_bought' => $last_shoe_size_bought,    'hs_last_non_shoe_size_bought' => $last_non_shoe_size_bought,    'updated' => date("Y-m-d H:i:s"),    '$consent' => array('email'));

...but hs_product_tags_purchased, hs_brands_purchased and hs_returned_product_ids don’t seem to be importing correctly as lists (the first 2 are lists of strings, the last one a list of integers.

I have tried sending them as native arrays, and also as json formatted strings (this is what $this->listify does, changes array(‘Herring’) into [“Herring”].

When I send as arrays, the value does not appear in the customer profile. When I try as a json formatted string ([“Herring”]) then the value appears in the customer profile as a string ‘[“Herring”]’ but cannot be searched using a ‘list contains’ query when creating a segment.

How do I import arrays as custom properties?

Many thanks,

Gareth

Best answer by alex.hong

Hi @dartacus,

Welcome to the Community.

I would suggest going through our Help Center article related to list data types and to double check your formatting. The format should be [“Item1, Item2”]. 
Additionally, I would like to point you to the Identify API reference you can also use. Lastly, you may have to update the data type in the segment to “List” so that it can be correctly populated.

 

Thanks!
Alex

View original
Did this topic or the replies in the thread help you find an answer to your question?

3 replies

alex.hong
Forum|alt.badge.img+58
  • Klaviyo Alum
  • 1552 replies
  • Answer
  • April 26, 2022

Hi @dartacus,

Welcome to the Community.

I would suggest going through our Help Center article related to list data types and to double check your formatting. The format should be [“Item1, Item2”]. 
Additionally, I would like to point you to the Identify API reference you can also use. Lastly, you may have to update the data type in the segment to “List” so that it can be correctly populated.

 

Thanks!
Alex


Forum|alt.badge.img+5
  • Author
  • Problem Solver III
  • 61 replies
  • April 27, 2022

Thank you. I have double-checked formatting and when I tested I chose ‘List’ in the dropdown. I will try an Identify call instead of /person.


Forum|alt.badge.img+5
  • Author
  • Problem Solver III
  • 61 replies
  • April 27, 2022

Yes, using /Identify with a json object rather than /person fixed this, arrays now import correctly. Thanks again.


Reply