I'm using the following code to submit events to GA:

                (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

    var ga = function() {};
    analytics('create', 'UA-90679999-1', 'auto');
    analytics('send', 'event', 'item', 'purchase', 'none', '0.13');

The manual says that the event value should be an integer and I've just verified that it doesn't work with non-integers.

However oddly enough some items have fractions in their prices, and it seems dumb to always have to divide the event/goal values I see in GA by 100 if I submit in cents. Is there a workaround to send non-integer values to GA?

  • It is very common to program currency into integers using cents. I'm not specifically familiar with GA in this respect, but I've used the technique in many other places. In fact there are good reasons NOT to use decimal numbers for currency. The way that computers handle decimals are not 100% compatible with base 10. That can lead to inaccuracies that show up in calculations involving money. See Why not use Double or Float to represent currency? Jun 22 '17 at 14:19
  • @StephenOstermiller yeah I understand that, keep money in integers - add comma when displaying, I actually do this on my site. But then the question is, how do I tell GA that I've submitted cents instead of dollars? The problem is that I see values like $5423,00, and have to remember to divide by 100 to get the actual value of $54.23
    – Bob
    Jun 22 '17 at 15:21
  • I haven't used it for event values before, but you could create a Calculated Metric to divide the value by 100. It wouldn't change the default event reports, but you could make a custom report with it. Jul 11 '17 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.