谷歌分析;使用自定义变量和事件 [英] Google Analytics; using custom variables with events

查看:513
本文介绍了谷歌分析;使用自定义变量和事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是将一些Google Analytics事件添加到网站。我以前从未使用过Google Analytics,而且我的基础知识正在运行,但尽管阅读了大量文档,但我不太了解自定义变量如何应用于事件。



例如,当用户点击按钮查看航班信息时,我有这样的代码:

  var scope = 3; //页面级作用域
_gaq.push(['_ setCustomVar',1,'FlightNumber',FlightNumber,scope]);
_gaq.push(['_ setCustomVar',2,'Departure',Departure,scope]);
_gaq.push(['_ setCustomVar',3,'Destination',Destination,scope]);
_gaq.push(['_ setCustomVar',4,'Destination',ETD,scope]);
var detail = FlightNumber +:+ Departure +=>+ Destination +@+ ETD;
_gaq.push(['_ trackEvent','Flight','View',detail]);

如果我在运行Google Analytics调试器扩展程序的情况下运行Chrome,则可以看到这些自定义变量似乎不过,当我访问Google Analytics(分析)页面时,找不到任何显示这些自定义变量的内容,但详细信息在这个事件的标签字段是正确的。



变量(正如我所希望的)是否与事件有关,或者我误解了它们的工作方式?如果是后者,我该如何根据各种参数来分析事件,例如出发,航班号等等?

我是否通过使用页面范围来做正确的事情?在我看来,这是正确的,因为每个事件(类似于页面访问)都可以有不同的出发地/目的地/等。



如果代码是正确的,我如何查看Analytics(分析)页面上的数据?例如,如何查看从某个特定的起飞机场观看了多少班机?

在相关说明中,我发现ETD(预计出发时间)变量 - 原始ETD变量的值为Wed May 01 2013 12:50:00 GMT + 0100(GMT Daylight Time),我可以在调试输出中看到自定义变量已设置:

  _gaq.push处理_setCustomVarfor args:[4,ETD,Wed May 01 2013 12:50:00 GMT + 0100( GMT日光时间),3]:

然而,随后的调试输出(我认为)跟踪事件信标显示:

 自定义变量4:label:'ETD'值:'undefined'范围:'Page'

那里有什么问题?为什么我的自定义变量的值设置不正确? 在GA中,所以如果你点击按钮,然后立即去GA看看它是否显示,你不会等待足够长的时间。您至少24小时不能正式开始担心。

2)您只有5个自定义变量插槽,并且根据您如何使用给定的自定义可变插槽,特别是范围参数,你可能会覆盖你的数据。您是否在其他地方使用自定义变量,以及您在其他地方使用的范围是什么?



3)为什么我的自定义变量设置不正确?我假设你的意思是它显示undefined..那是因为你传递给GA的参数的javascript变量是未定义的;这对于GA代码来说并不是问题,无论你在哪里(而不是)定义该javascript变量,这都是一个问题。


I've been tasked with adding some Google Analytics events to a web site. I've never used Google Analytics before, and I have the basics working, but despite having read lots of documentation I don't really understand how/if custom variables apply to events.

For example, I have code like this when the user clicks a button to view information about a flight:

    var scope = 3; // page-level scope
    _gaq.push(['_setCustomVar', 1, 'FlightNumber', FlightNumber, scope]);
    _gaq.push(['_setCustomVar', 2, 'Departure', Departure, scope]);
    _gaq.push(['_setCustomVar', 3, 'Destination', Destination, scope]);
    _gaq.push(['_setCustomVar', 4, 'Destination', ETD, scope]);
    var detail = FlightNumber + ": " + Departure + " => " + Destination + "@" + ETD;
    _gaq.push(['_trackEvent', 'Flight', 'View', detail]);

If I run Chrome with the Google Analytics Debugger extension running, I can see that these custom variables seem to be getting set and a tracking beacon is sent.

But when I visit the Analytics page, I can't find anything that shows these custom variables, although the detail information in the label field of the event is right.

Are the variables (as I hope) somehow related to the event, or have I mis-understood how they work? If the latter, how can I analyse the events based on the various parameters such as departure, flight number, etc?

Am I doing the right thing by using page scope? It seems to me the correct thing, because each event (which is analogous to a page visit) can have different departure/destination/etc.

If the code is right, how do I see the data on the Analytics page? For example, how can I see how many flights from a particular departure airport were viewed?

On a related note, I see a problem with the ETD (Estimated Time of Departure) variable - the original ETD variable has a value such as "Wed May 01 2013 12:50:00 GMT+0100 (GMT Daylight Time)", and I can see in the debugging output that the custom variable is set:

    _gaq.push processing "_setCustomVar" for args: "[4,ETD,Wed May 01 2013 12:50:00 GMT+0100 (GMT Daylight Time),3]":  

However the subsequent debugging output that (I think) decodes the tracking event beacon shows this:

    Custom Var 4             : label:'ETD' value:'undefined' scope:'Page'

What's the problem there? Why has my custom variable's value not been set correctly?

解决方案

1) Officially, data can take up to 24 hours to show up in GA, so if you are clicking the button and then immediately going to GA to see if it shows up, you're not waiting long enough. You can't officially start worrying for at least 24 hours.

2) You only have 5 custom variable slots, and depending on how you use a given custom variable slot, particularly the scope argument, you may be overwriting your data. Are you using custom variables somewhere else, and what scope are you using for them elsewhere?

3) "why is my custom variable not being set correctly?" I assume you mean that it is showing "undefined".. well that is because the javascript variable you are passing as an argument to GA is undefined; that's not a problem with your GA code, that's a problem with wherever you are (not) defining that javascript variable.

这篇关于谷歌分析;使用自定义变量和事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆