3

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?

Henrik Söderlund
  • 4,286
  • 3
  • 26
  • 26
  • What does the https://ga-dev-tools.appspot.com/query-explorer/ return? I wonder if its the website that just cant display decimals. Measurement protocol should be accepting them – Linda Lawton - DaImTo Jun 30 '16 at 08:24
  • 2
    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. – Linda Lawton - DaImTo Jun 30 '16 at 08:26
  • 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 Jun 30 '16 at 12:22
  • 1
    If you didn't know about them try https://developers.google.com/analytics/devguides/collection/protocol/v1/validating-hits and https://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 :/ – Linda Lawton - DaImTo Jun 30 '16 at 12:23
  • My findings: 1. Decimals are accepted for custom metrics. The documentation for the measurement protocol should be updated. 2. The status code 200 that is returned does in fact _not_ mean 200 at all if a value was incorrectly formatted. I would consider that a bug. – Henrik Söderlund Jun 30 '16 at 12:24
  • 1
    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 Jun 30 '16 at 12:25

1 Answers1

3

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.

Philip Walton
  • 29,693
  • 16
  • 60
  • 84