I have a function which handles tracking of a certian event, like so:
var trackAddress = function (providedProduct, searchedProduct) {
_trackEvent('Address found', providedProduct, searchedProduct);
}
Now what will happen if searchedProduct is undefined or an empty string?
The thing is, in Google Analytics I can see that the sum of all event actions is equal to the total number of events. That is not the case in event labels.
What could be the cause for this?
I'm sure you know this, but for the sake of argument this is the anatomy of an event tracker:
_trackEvent(category, action, opt_label, opt_value, opt_noninteraction)
Now in case a required parameter is missing (like action in your case) there's must be a mechanism within Google Analytics that will invalidate the event altogether. Conversely, an optional parameter, won't affect the event tracking but rather the report. To sum up, the result is the same: Loss of data.
A possible way around this to provide default parameters for your function arguments like so:
providedProduct = typeof a !== 'undefined' ? providedProduct : "defaultValue";
Further Reading: Setting Up Event Tracking
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With