[英]Google analytics not sending custom dimensions with pageview hits
I'm using google analytics to track page views on my site.我正在使用谷歌分析来跟踪我网站上的页面浏览量。 trying to send custom dimensions during my pageviews.
试图在我的综合浏览量期间发送自定义尺寸。 Here is what I have for the JS code
这是我的 JS 代码
ga("create", '<UA-tracking ID goes here-01>', {
'name': 'TrackingID3'
});
// SendPageView
ga(function () {
var trackers = ga.getAll();
trackers.forEach(function (tracker) {
ga('set', 'dimension1', '187989840'); // departmentId
ga('set', 'dimension2', 'BLUE JEANS'); // caseName
tracker.send("pageview");
});
});
The code above works but it does not send the custom dimensions上面的代码有效,但它不发送自定义尺寸
I made a new web project and a new google analytics account (new email).我创建了一个新的 web 项目和一个新的谷歌分析帐户(新电子邮件)。 Everything is set up and working in the new google analytics account.
一切都已设置并在新的谷歌分析帐户中运行。 Here is the code i have for the second web project
这是我为第二个 web 项目准备的代码
ga('create', 'UA-tracking ID goes here-01', {
'cookieDomain': 'none'
});
// SendPageView
ga(function () {
var trackers = ga.getAll();
trackers.forEach(function (tracker) {
var dimensionValue = '187989840'; // departmentId
ga('set', 'dimension1', dimensionValue);
var dimensionValue = 'BLUE JEANS'; // caseName
ga('set', 'dimension2', dimensionValue);
tracker.send("pageview");
});
});
I tested the new web project and it successfully send the custom dimensions我测试了新的 web 项目,它成功发送了自定义尺寸
Any Idea what I'm doing wrong?知道我做错了什么吗?
there's a collision of using ga('set',...)
command and tracker name parameter in the ga('create', ...)
command.在
ga('create', ...)
命令中使用ga('set',...)
命令和跟踪器名称参数会发生冲突。 To avoid this you might want to use specific tracked method:为避免这种情况,您可能需要使用特定的跟踪方法:
trackers.forEach(function (tracker) {
var dimensionValue = '187989840'; // departmentId
tracker.set('dimension1', dimensionValue);
// ...
tracker.send("pageview");
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.