命令被忽略.未知目标:在 Google Analytics 跟踪代码中设置自定义维度时未定义 [英] Command ignored. Unknown target: undefined when setting Custom Dimension in Google Analytics tracking code
问题描述
我正在 Google Analytics 跟踪代码中设置自定义维度,但是我在打开 Google Analytics 调试器的 Chrome 控制台中看到一个奇怪的错误.
I am setting up a Custom Dimension in my Google Analytics Tracking Code, however I am seeing a strange error in the Chrome Console with the Google Analytics Debugger switched on.
这是我在每个页面上触发的代码.我正在向一个区域帐户以及一个全局/汇总帐户报告,我已经创建了两个跟踪器来实现这一目标.
This is my code which is fired on every page. I am reporting to a regional account as well as a global/rollup account and I have created two trackers to achieve this.
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-85521872-1', 'auto', 'crmpiccoglobal');
ga('create', 'UA-85521872-3', 'auto', 'crmpiccoregion');
ga('set', 'dimension1', 'premium');
ga('crmpiccoglobal.send', 'pageview');
ga('crmpiccoregion.send', 'pageview');
</script>
在控制台中我看到:
运行命令:ga("set", "dimension1", "premium")
Running command: ga("set", "dimension1", "premium")
analytics_debug.js:10 命令被忽略.未知目标:未定义
analytics_debug.js:10 Command ignored. Unknown target: undefined
我在 GA 中的每个属性下都创建了自定义维度.
I have created the Custom Dimension in GA under each property I want to access it in.
推荐答案
您需要在set"命令中使用您的跟踪器名称,否则 GA 会将命令应用于默认跟踪器 t0(在您的示例中不存在)):
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');
这篇关于命令被忽略.未知目标:在 Google Analytics 跟踪代码中设置自定义维度时未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!