Command ignored. Unknown target: undefined when setting Custom Dimension in Google Analytics tracking code

微笑、不失礼 提交于 2019-12-04 02:49:28
Eike Pierstorff

You need to use your tracker names in the "set" command, else GA will apply the command to the default tracker t0 (which does not exist in your example):

  ga('crmpiccoglobal.set', 'dimension1', 'premium');
  ga('crmpiccoregion.set', 'dimension1', 'premium');

  ga('crmpiccoglobal.send', 'pageview');
  ga('crmpiccoregion.send', 'pageview');

If you use Google Tag Manager to load your Google Analytics and you don't know what tracker is being created, use this:

sendGa(name : string, data: any) {
    (<any>window).ga(() => {
        var trackers = (<any>window).ga.getAll();
        var firstTracker = trackers[0];
        var trackerName = firstTracker.a.data.values[":name"];
        (<any>window).ga(trackerName + '.' + name, data);
    });
}

docs: https://developers.google.com/analytics/devguides/collection/analyticsjs/accessing-trackers

I would recommend to use the debug version of the analytics.js library analytics_debug.js and you will see the causes of the bugs in the console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!