In analytics.js you can set a custom property like so:
ga('set', 'foo', 'bar');
How to do this is the older legacy version?
I'm basically trying to do the equivalent of this:
var ua = navigator.userAgent || navigator.vendor || window.opera;
ga('set', 'dimension1',(ua.indexOf("FBAN") > -1) || (ua.indexOf("FBAV") > -1) ? 'Facebook' : 'None');
dimension1
is something I got from the analytics dashboard when I created a "custom dimension". Following instructions from here not that it's relevant but still ( http://oko.uk/blog/tracking-inapp-browsers ).
So I'm not sure if this counts as a custom var...
You can use the function _setCustomVar(index, name, value, opt_scope)
for creating a custom variable, like below -
_gaq.push(['_setCustomVar',
1, // This custom var is set to slot #1. Required parameter.
'Items Removed', // The name acts as a kind of category for the user activity. Required parameter.
'Yes', // This value of the custom variable. Required parameter.
2 // Sets the scope to session-level. Optional parameter.
]);
_gaq.push(['_trackEvent',
'Shopping', // category of activity
'Item Removal', // Action
]);
Please check the following link for more details https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables
I don't think google even supports this anymore.
_gaq.push(['_setCustomVar', category, action, label]);
You can read more in the documentation. https://developers.google.com/analytics/devguides/collection/gajs/#one-push-multiple-commands
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.