"&" sign in product name or category not submitting using Track API

  • 9 May 2022
  • 1 reply

Badge +2


I am integrating Track Api to post ‘Placed Order’ event data using PHP curl. It is working fine but if any data string contains ‘&’ or ‘&’ then it is not submitting data.

Example: "ProductName": "Winnie & Pooh", "Categories": [ "Fiction & Drama", "Children" ]

Code Sample

$data = 'data={ "token": "my_token", "event": "Placed Order", "customer_properties": { "$email": "", "$first_name": "John", "$last_name": "Smith" }, "properties": { "$event_id": "1234_WINNIEPOOH", "$value": 9.99, "OrderId": "1234", "ProductID": "1111", "SKU": "WINNIEPOOH", "ProductName": "Winnie & Pooh", "Quantity": 1, "ProductURL": "", "ImageURL": "", "Categories": [ "Fiction & Drama", "Children" ], "ProductBrand": "Kids Books" }, "time": 1387302423 }';

   $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "");
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS,  ($data));
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: text/html'));
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $data = curl_exec($ch);   
    $data = json_decode($data, true);



Best answer by Dov 9 May 2022, 17:02

View original

1 reply

Userlevel 7
Badge +61

Hi @sachinuser,

Thanks for sharing this with the community.

I noticed you’re already working towards a solution with a member of our support team on this issue. I recommend you continue working with them to investigate the details of your API call for the time being.