我正在尝试绑定(bind)事件以通过 Google Analytics 进行事件跟踪。 在调用 GA 时,我们也可以发送一些值。
我正在尝试通过 DOM 选择器发送值。
当我使用时:
myValue=function(){return parseInt($('.checkout-order-totals .order-total td:last').text().replace('$','').replace(/,/g,'')).valueOf(); }
它工作得很好(在omnibug中显示点击事件)。
但是当我从上面的代码中删除 parseInt 时, 即,
myValue=function(){return $('.checkout-order-totals .order-total td:last').text().replace('$','').replace(/,/g,'').valueOf(); }
它不会向 GA 发送请求。 (在omnibug中不显示点击事件)
造成这种情况的可能原因是什么?
最佳答案
根据GA documentation ,Value
参数必须是JS Number。
因此,请求未发送也就不足为奇了,因为它肯定无法通过某些验证。
关于javascript - 在谷歌分析中发送字符串值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26250164/