3
votes

We need to send a decimal value to google analytics, and had decided to do this using a custom metric of the type "Currency". In the Tracking documentation it says that this should be allowed:

If the custom metric is configured to have a currency type, you can send decimal values.

https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets#sending_data

However, we are sending in raw data using the measurement protocol, and in that documentation it says that only integers are allowed for custom metrics: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cm_

I have noticed that the decimal values we send in do not show up in the UI. Could this be the reason?

1
What does the ga-dev-tools.appspot.com/query-explorer return? I wonder if its the website that just cant display decimals. Measurement protocol should be accepting themDaImTo
If you can verify somehow that you are sending a decimal to a custom metric with the measurement protocol and the query explorer is returning a int and not the decimal we can log it as a bug and I will ping Google for you. Either way I think the documentation is a bit confusing I agree with you there.DaImTo
After many failed attempts, I managed to get the data into analytics. It turns out that it was another field that was causing the requests to fail, namely eventvalue, where we also used a decimal. Turns out that eventvalue can only be integers.Henrik Söderlund
If you didn't know about them try developers.google.com/analytics/devguides/collection/protocol/… and ga-dev-tools.appspot.com/hit-builder very useful when sending stuff to Google Analytics. I have been there last week I spent two days on an invalid request :/DaImTo
The hitbuilder is indeed awesome! I was unaware of it at first, but my colleague pointed me to it, and it was then that I noticed the problem with eventvalue.Henrik Söderlund

1 Answers

3
votes

Custom metrics are not limited to just integer types. They can be whatever type you want, as long as it corresponds to the type you set when creating them in the Google Analytics admin interface.

In short: custom metric values should be integers for metrics of type Integer or Time, and they can be integers or floating point numbers for metrics of type Currency.

The documentation was incorrect (when this question was asked), but it has been updated to clarify this ambiguity.