我已创建自定义维度 streamIdMismatch
和自定义指标
具有相同名称streamIdMismatch
此外,我还根据我的维度和指标创建了自定义报告:
现在我想将一些数据发布到我的报告中,我使用以下 javascript
代码:
var metricValue = '123';
ga('set', 'metric1', metricValue);
但在报告中我什么也没看到......
最佳答案
Eike Pierstorff
和 Vinoaj
都是对的。设置自定义维度或指标不会执行任何操作。您必须将它们与点击关联起来:
https://support.google.com/analytics/answer/2709828#collection
Unlike other types of data, custom dimensions and metrics are sent to Analytics as parameters attached to other hits, like pageviews, events, or ecommerce transactions. As such, custom dimension or metric values need to be set before a tracking call is made in order for that value to be sent to Analytics.
例如:
ga('create', 'UA-XXXX-Y', 'auto');
var metricValue = 123;
ga('set', 'metric1', metricValue);
ga('send','event', 'My Category',','metric1',metricValue);
或者:
ga('create', 'UA-XXXX-Y', 'auto');
var metricValue = 123;
ga('set', 'metric1', metricValue);
ga('send', 'pageview');
此外,如果您仅设置自定义指标
,但创建的报告包含尚未设置的自定义维度
,则可能会遇到一些意外的报告问题.
关于javascript - 从 javascript 将数据发布到自定义 Google Analytics 指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47353943/