gtag:未发送事件的维度(如何发送?)

时间:2018-02-06 10:40:51

标签: javascript google-analytics gtag.js

我使用新的API gtag进行谷歌分析。我想发送具有特定维度的事件,而不是为在页面加载开始时配置的每个事件设置公共维度。

我尝试这样做:

parameters.softwareOwner = HelperJSViewBag.getValue("softwareOwner");
parameters.softwareVersion = HelperJSViewBag.getValue("softwareVersion");
parameters.event_category = this.category.name;
parameters.event_label = this.description;
parameters.metricValue = 1;
parameters.customerID = cookieCustomer.id;
parameters.customerSessionID = cookieCustomer.id_session;
parameters.customerPartnerID = localStorageCustomer.partnerID;
parameters.customerName = localStorageCustomer.firstName + " " + 
localStorageCustomer.lastName;
gtag('event', parameters.metricName, parameters);

我正在使用tag assistance (by google)来跟踪指标是否已发送到Google Analytics并且正在发送,但仅包含维度event_categoryevent_label

enter image description here

我可以做什么?如果没有,有任何替代方法可以实现我想要的目标吗?

1 个答案:

答案 0 :(得分:1)

我发现了我的问题here。谷歌分析无法识别我发送的任何维度,至少使用我给出的名称。我需要的是用谷歌给出的服装名称映射每个名称。此名称由“dimension”+ index(例如:dimension5; dimension6)组成。

parameters.softwareOwner = HelperJSViewBag.getValue("softwareOwner");
parameters.softwareVersion = HelperJSViewBag.getValue("softwareVersion");
parameters.event_category = this.category.name;
parameters.metricName = this.name;
parameters.event_label = this.description;    
parameters.metricValue = 1;
parameters.customerID = cookieCustomer.id;
parameters.customerSessionID = cookieCustomer.id_session;
parameters.customerPartnerID = localStorageCustomer.partnerID;
parameters.custom_map = {
    "dimension1" : "softwareOwner",
    "dimension2" : "softwareVersion",
    "dimension3" : "customerID ",
     .........
}
gtag('event', parameters.metricName, parameters);