我正在使用redux-beacon发送谷歌分析点击数。它在Event Tracking上工作得很好,但在User Timings上却失败了。正如我在doc for User Timing上看到的,它需要timingCategory、timingVar和timingValue,但redux-beacon发送它时没有使用timing前缀。
以下代码在trackEvent的redux-beacon日志中生成一个有效的事件,并为trackTiming生成失败的事件。
import {trackTiming, trackEvent} from '@redux-beacon/google-analytics';
const userTiming = trackTiming(action => {
return {
category: 'Test category',
var: 'load',
value: 3549,
label: action.type
};
});
const event = trackEvent(action => {
return {
category: 'Test category',
action: action.type,
label: 'Test label',
value: 45
};
});
export const eventsMap = {
USER_TIMING_ACTION: userTiming,
EVENT_ACTION: event
};它给出了以下错误:
Running command: ga("send", {hitType: "timing", customTrackerId: undefined, category: "Test category", var: "load", value: 3549, label: "USER_TIMING_ACTION"})
Set called on unknown field: "customTrackerId".
Set called on unknown field: "category".
Set called on unknown field: "var".
Set called on unknown field: "value".
Set called on unknown field: "label".
Missing required field '"timingCategory"' for hit of type '"timing"'
Missing required field '"timingVar"' for hit of type '"timing"'这是userTracking控制台中redux-beacon打印的内容
hitType: "timing", customTrackerId: undefined, category: "Test category", var: "load", value: 3549, var: "load"}我做错了什么,或者是redux-beacon跟踪时间的错误?
我正在使用的版本:
"@redux-beacon/google-analytics": "1.0.2",
"@redux-beacon/logger": "1.0.0",
"redux-beacon": "2.0.3"发布于 2018-08-02 08:22:49
这是一个事件帮助器的错误。现在已经修好了。请升级到GA目标的最新版本:
npm install --save @redux-beacon/google-analytics@1.0.3作为补充提示。如果事件帮助器有任何问题,如果你需要快速修复,你可以很容易地不使用它们。
例如,在您的情况下,您可以这样写:
const userTiming = action => ({
hitType: 'timing',
timingCategory: 'Test category',
timingVar: 'load',
timingLabel: action.type,
});
export const eventsMap = {
USER_TIMING_ACTION: userTiming,
};以下是有关编写事件定义的文档:https://rangle.gitbook.io/redux-beacon/index-1/event-definition
感谢您抽出时间来撰写文章,提出问题,并强调您所遇到的问题。有这么多不同的目标和事件帮助器,像这样的bug报告是非常有用的。
https://stackoverflow.com/questions/51634978
复制相似问题