小编Dif*_*iff的帖子

如何为Google Analytics事件跟踪设置appVersion

当我尝试在Google Analytics中设置appVersion时,我的事件跟踪会停止工作.具体来说,我正在尝试将应用程序版本包含在事件跟踪中,以便我知道应用程序的哪个版本导致了事件.

我试过像这样设置应用版本:

ga('set', 'appVersion', app.version);
Run Code Online (Sandbox Code Playgroud)

我试过这样的:

ga('send', 
   'event', 
   eventCategory, 
   eventAction, 
   {'page': pageName, 'appVersion' : app.version });
Run Code Online (Sandbox Code Playgroud)

我也尝试了替代语法:

ga('send', 
   {'hitType' : 'event',
    'eventCategory' : eventCategory,
    'eventAction' : eventAction,
    'page' : pageName,
    'appVersion' : app.version});
Run Code Online (Sandbox Code Playgroud)

如果我包含appVersion,则事件跟踪将停止工作.没有事件实时显示,并且第二天没有在行为/事件部分显示.PageViews仍然有用.

根据评论中的要求,我正在编辑以添加我的事件跟踪代码.我尝试解决这个问题时经历了几个变化.这是目前的样子.

var app = {
    trackEvent: function (pageName, eventCategory, eventAction, optionalEventLabel, optionalEventValue) {

        var eventObject = {
            'eventCategory' : eventCategory,
            'eventAction' : eventAction,
            'optionalEventLabel' : optionalEventLabel,
            'optionalEventValue' : optionalEventValue,
            'page' : pageName,
        };

        console.log("app.trackEvent - " + JSON.stringify(eventObject));

        ga('send', 'event', eventObject);
    }
} …
Run Code Online (Sandbox Code Playgroud)

google-analytics event-tracking

6
推荐指数
1
解决办法
3627
查看次数

标签 统计

event-tracking ×1

google-analytics ×1