I know that second value after splitting __utma
cookie is a visitor unique id. How can I obtain that in proper way? Something like this: var uid = _ga.visitor.getUid();
I know that second value after splitting __utma
cookie is a visitor unique id. How can I obtain that in proper way? Something like this: var uid = _ga.visitor.getUid();
- You should add to the question why you want to get this number. This is a random id used internally by Google Analytics. This number is not available on GA interface. Hard to think about a real use case to use it. – Eduardo Commented Nov 26, 2012 at 14:54
- Payment transaction starts on web site (frontend), this event tracked successful. But thus transaction ends on backend (when payment system callback us). Not in all times we have thus events trackend from frontend. Hence we want use php GA framework to push events to GA directly from backend. – Ivan Velichko Commented Nov 26, 2012 at 15:30
3 Answers
Reset to default 5_gaq.push(function(){
var tracker = _gat._getTrackers()[0];
var visit_code = tracker._visitCode();
console.log(visit_code);
});
UPDATE
_visitCode()
is an undocumented method but it has been around for at least one year as far as I know. My guess is that Google will not get rid of it, since it's concentrating it's new efforts on implementing Universal Analytics that has a different approach.
The 2 options you have here is to either use this undocumented method or fiddle with a cookie that also has an undocumented format. So both are somewhat unreliable.
On the time of this posting Universal Analytics is still in beta.
As per this: https://developers.google./analytics/devguides/collection/gajs/methods/gaJSApi_gat#_gat._getTrackerByName
Getting the tracker:
var tracker = _gat._getTrackerByName();
Now get the visit code:
var visitcode = tracker._visitCode();
Or one liner:
var visitcode = _gat._getTrackerByName()._visitCode();
I think the proper and only way is to split the __utma
cookie as you say.
Since you may and can assume the second value always is the id this is pretty safe
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744890756a4599398.html
评论列表(0条)