如何使用@ redux-beacon / google-analytics使多个跟踪器正常工作?

时间:2019-06-10 16:08:35

标签: google-analytics redux-beacon

我在我的项目中使用redux-beacon和google-analytics来跟踪两个Google Analytics(分析)帐户中的电子商务事件。由于并非所有数据都在报告中传递,因此我尝试使用Google Analytics(分析)Debugger Chrome扩展程序来调试出错的地方。似乎所有调用都抛出“在未知字段上调用了Set:“ customTrackerId”。有人遇到过吗?

import {
  trackEcommProduct,
  trackEcommAction,
  trackPageView,
  trackEvent
} from '@redux-beacon/google-analytics';

export const CLIENT_TAG = 'client';

const getLocation = () => window.location.href;
const getPage = () => getLocation().split('#')[1];

export const clientPageView = trackPageView((action, prevState, nextState) => ({
  location: getLocation(),
  page: getPage(),
  title: action.title
}), CLIENT_TAG);

通过chrome扩展程序在控制台上吐出事件:

VM20555 analytics_debug.js:15 Executing Google Analytics commands.
VM20555 analytics_debug.js:15 Running command: ga("client.set", "page", "/product/4")
VM20554 app.ba606e9ace53a50ecd21.js:93766 CC client.
VM20555 analytics_debug.js:15 Executing Google Analytics commands.
VM20555 analytics_debug.js:15 Running command: ga("client.send", {hitType: "pageview", customTrackerId: "client", page: "/product/4", title: undefined, location: "http://localhost:3333/#/product/4"})
VM20555 analytics_debug.js:15 Set called on unknown field: "customTrackerId".
VM20555 analytics_debug.js:15 
Sent beacon:
v=1&_v=j76d&a=291005201&t=pageview&_s=1&dl=http%3A%2F%2Flocalhost%3A3333%2F%23%2Fproduct%2F4&dp=%2Fproduct%2F4&ul=es-es&de=UTF-8&dt=Here's%20a%20title%20from%20setting%3A%20frontoffice_title&sd=24-bit&sr=1440x900&vp=830x766&je=0&_u=SCCACEIJB~&jid=&gjid=&cid=709854029.1557150989&tid=UA-62066942-1&_gid=86805739.1559994923&z=310945797

1 个答案:

答案 0 :(得分:1)

感谢您指出这一点。这似乎是我们的问题。 trackPageView事件帮助器向事件添加了customTrackerId属性,以使我们能够使用给定的跟踪器ID(或一组跟踪器ID)进行匹配。这个属性不需要存在于redux-beacon之外,因此我已经从任何传出事件中解析了它。我已经发布了新版本的google-analytics目标:

npm install @redux-beacon/google-analytics@1.2.2

试试看,让我知道它是否解决了您的问题!