访问先前存储的访客级自定义变量 [英] Access previously stored Visitor-level custom variable

查看:70
本文介绍了访问先前存储的访客级自定义变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Google Analytics中,访问者级别的自定义变量存储在Cookie中。



我只想将一些数据存储在GA自定义变量之前没有数据存储在此插槽中,即从不覆盖访问者级自定义变量。



有没有什么办法可以做到这一点,无论是通过测试是否已经存储了一些数据,或者通过检索存储值?



没有 _getCustomVar ,但是任何方式,我可以做一些相当的事情,而不是黑客入我自己的cookie?

_getVisitorCustomVar(index)

例如:

  _gaq.push(function (){
var pageTracker = _gat._getTrackerByName(); //获取默认的跟踪器
var visitorCustomVar1Value = pageTracker._getVisitorCustomVar(1);
});

它只适用于Visitor级别的自定义var,因为这是GA cookie中唯一存储的客户端大小 __ utmz 。但是,这正是你想要的我猜。



如果你想查看是否已经设置了非访客级定制变量,那么你需要当您将自定义var设置为可以稍后检索时,自己编写存储单独cookie的逻辑。但它应该是一个简单的事情,并且可能比侵入私有cookie更好。


In Google Analytics, Visitor-level custom variables are stored in cookies.

I'm looking to store some data in a GA custom variable only if no data has been stored in this slot before, i.e. never overwrite visitor-level custom variables.

Is there any way I can do that, either by testing whether some data has already been stored, or by retrieving the stored value?

There's no _getCustomVar, but is there any way I can do something equivalent without "hacking" into the cookies myself?

解决方案

There is _getVisitorCustomVar(index).

eg:

_gaq.push(function() {
  var pageTracker = _gat._getTrackerByName(); // Gets the default tracker.
  var visitorCustomVar1Value = pageTracker._getVisitorCustomVar(1);
});

It only works for Visitor level custom var because that's the only one stored client size in the GA cookie __utmz. But that's exactly what you are looking for I guess.

If you want to see if a non-visitor level custom var that has already been set, then you would need to write the logic yourself storing a separate cookie when you set the custom var to be able to retrieve later. But it should be a simple thing and probably better idea than hacking into proprietary cookies.

这篇关于访问先前存储的访客级自定义变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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