Have you ever been frustrated by attempting to visit a particular website, only to discover a red page with the text stating “malware detected” instead? Believe it or not, but this is Google's way of keeping you safe.
What if I was to tell you that some Google Analytics Events are not always processed and can become completely lost? That's right. Never to be found and rejected by Google Analytics servers immediately.
Well, to cut a long story short - do not send floating point numbers as an Event Value or your Google Analytics events will not be delivered.
Absolutely the same situation with the Timing hit, the UTT (User timing time) parameter is an integer, while your timing calculation may involve floating numbers. Google Analytics will drop these timing hits without even telling you.
If you are using the Google Analytics Debugger (a must-have tool to debug your GA and GTM implementation) you will see a perfectly normal looking request in your console. But don't let this tool fool you - the request will be rejected by Google Analytics and lost for good!
Let's check it out. Google Analytics has a nice debugging tool. We are going to manually construct a Google Analytics Event Hit and try integer and floating point numbers as the Event value. If you are not familiar with GA Measurement Protocol, just trust that the Hit URL is right or copy/paste the Hit URL from your browser's network explorer.
Open the following URL (don't forget to replace UA-XXXXXXXX-X with YOUR Google Analytics ID) in your browser:
Note the &ev=49.95 parameter in the URL - it is telling Google Analytics to use 49.95 as the Event Value. The /debug/ part means that Google Analytics will only parse the request without saving it. You should see this message in response:
"description": "The value provided for parameter 'ev' is invalid. Please see http://goo.gl/a8d4RP#ev for details.",
Now, change the the &ev=49.95 inside URL to &ev=50 and try again.
All good. If you remove /debug from the URL, you will send the Event to your Google Analytics property and should see it in the Real-Time reports of the corresponding View.
Despite the fact that the Google Analytics Measurement Protocol debugging tool is giving you a warning, it's not going to process this event. You will not find it in your reports. It's lost, disregarded and not processed by Google Analytics servers. The same applies to Analytics 360, formerly known as Google Analytics Premium.
You need to know about it!
There are lots of real-world situations where you might lose your data without realising it.
Say, you have an amazing product and you price it right: $49.95 - under $50, what a deal!
You sell it on your website and in addition to Google Analytics E-Commerce or Enhanced E-Commerce you want to track Total Transaction Value as a Google Analytics Event Value. What could be easier? On your thank you page, shown immediately after the transaction, you insert the following code:
<script> ga('send', 'event', 'Transaction', 'Product Name', 'Product Variation', 49.95); //49.95 is a TTV: Total Transaction Value </script>
A day later, you checked your Google Analytics reports (Behavior / Events / Top Events) and were surprised to see exactly zero events with the category name Transaction. Your E-commerce reports have transaction data, so something went wrong!
According to the Google Analytics Measurement Protocol Parameter Reference, the Event Value should be non-negative AND Integer. Not floating point number! Because you had an invalid value (from GA point of view), the event is not processed at all. Just ignored. Not automatically rounded, not assigned to zero: the whole event is ignored.
Data is lost.
This is just great! How am I supposed to see an exact Total Transaction Value? The short answer - you don't. Google Analytics provides you with a simple and effective way to track transaction: E-Commerce tracking. If it's too simple for you, use Enhanced E-Commerce. Those tools can cover most E-commerce tracking needs.
If you still want to track the transactions as Events - let's do this!
The first and obvious solution would be to mathematically round the value. The code below will send 50 as the Event Value.
ga('send', 'event', 'Transaction', 'Product Name', 'Product Variation', Math.round(49.95)); //49.95 is a TTV: Total Transaction Value
What if those 5 cents are important to you? There is no way you are going to save a floating point number in Google Analytics as an Event Value - so you need to convert floating point to integer. If we are talking price, we can multiply by 100 (or 100,000). If we are talking seconds - multiply by 1,000 or 1,000,000 depending on the precision you require. The following will save your cents, but don't forget to divide your event-based Total Transaction Value by a hundred in your reports - otherwise your sales will go up immediately according to the report :)
var productPrice = 49.95;
ga('send', 'event', 'Transaction', 'Product Name', 'Product Variation', Math.round(productPrice * 100));
With Calculated Metrics - a new and amazing feature of Google Analytics and Analytics 360 (formerly known as Google Analytics Premium) we can still display real numbers. Create a Custom Metric by navigating to the Admin section of your Google Analytics View and click on Calculated Metrics, New Calculated Metric.
Google Analytics does not really tolerates treating it's limits and specifications freely. Please refer to the Google Analytics Limits article for the full list of Google Analytics limits.
Hope the above makes sense and will help you avoid this mistake while you are tagging your website and/or mobile app. We should never loose our data, especially Google Analytics Events with floating point numbers.
Please contact Internetrix and me foran extensive audit of your tagging solution. Happy reporting guys!
Internetrix is a certified Google Analytics and Analytics 360 Suite Partner who speaks your business language and is ready to help you understand your customers better. Please contact us, if you require assistance setting up tagging and Analytics data collection.