Issue with metadata values sent via API

Hi All, New here and trialling SA.

I’m tracking pageviews with the script but want to track key events like order completions via the API to ensure that all data is tracked and not blocked by ad blockers.

I am successfully sending the events to SA and can see the events but non of the values in my metadata are being stored.

An example of what is being sent (in json format) is
{“event”:“Add-to-Cart”,“metadata”:{“Product_ID”:“DELTA180W”,“Quantity”:1},“hostname”:“”,“ua”:“Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36”,“type”:“event”}

The event is logged along with the ua. The metadata fields are also being sent and stored and are recognised in the Events page (as columns) and the goals page (as filters) but the values are all empty.

I have also exported the data and again the fields are recognised but no values are exported.

I don’t know if I am doing something stupid (I don’t think I am) or is there an issue on the SA side. Perhaps a known issue.

Any help appreciated.

Thanks, we are trying to fix this. It’s a bug! Some metadata fields do not save.

Thanks Adriaan,

Woke up this morning to find all my metadata being collected as it should.

Looks like you’ve won over a customer.

Hi Adriaan,

I’m still having a bit of an issue with the metadata, in particular for a number fields which I’m submitting.

I’m sending the value of an order for example 137.48 (2 decimal places) but the value displayed in my events is 137.47999572753906

Every value that I send over is changed to 14 or 15 decimal places. I have no idea where it’s getting these values from so I started logging the json values that are being sent and they are all correct with only two decimal places.

Here is an example of the complete data set sent to you which then turned in to the value above.

{“event”:“Order Complete”,“referrer”:“”,“timezone”:“Europe/London”,“metadata”:{“Order_ID”:93782,“GBP”:137.48,“Date”:“2024-05-05 15:23:38”},“hostname”:“”,“ua”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36”,“type”:“event”}

When storing the number 137.48 in JavaScript, it might appear as 137.47999572753906 due to how floating-point numbers are represented in binary format. This is a common issue resulting from the limitations of binary representation. We will convert all data types to text (with a few exceptions like currencies). When doing that, we will take a look at this issue as well.

Hi, Just to be clear I’m not sending the data via Javascript. I’m sending via PHP and your API.

Is there any reason why the numbers are stored as numbers and not text? It doesn’t appear that we can do anything with the numbers anyway.

It’s not the sending that’s the problem. It storing it. We store it in Elasticsearch, the problem is in there. It will be fixed in the future!