©2012 Google -
Code Home -
Site Terms of Service -
Privacy Policy -
Site Directory
Google Code offered in:
English -
Español -
日本語 -
한국어 -
Português -
Pусский -
中文(简体) -
中文(繁體)
The _gaq global object can be used directly for asynchronous page tracking via the push(...) method. It also has methods for creating tracker objects, but these should only be used in rare cases.
For traditional page tracking, use the _gat global object instead.
_createAsyncTracker(accountId, opt_name) deprecated_getAsyncTracker(opt_name) deprecatedpush(commandArray)_createAsyncTracker(accountId, opt_name)_gat._createTracker(opt_account, opt_name) instead.'', which represents the default tracker in the
asynchronous syntax.
If an asynchronous tracker already exists for the given name, it
will be overwritten with the new tracker._gaq. It should
only be used in rare cases.
_gaq._createAsyncTracker('UA-65432-1');
String accountId The full web property ID (e.g. UA-65432-1) for the tracker object.
String opt_name The name to store the tracker object under. Use this name to refer to the tracker object in asynchronous tracking calls later.
Tracker The created tracking object._getAsyncTracker(opt_name)_gat._getTrackerByName(opt_name) instead.'')
will be used. If no tracker object exists with the given name,
a new tracker is created, assigned to that name and returned._gaq. It should
only be used in rare cases.
_gaq._getAsyncTracker();
String opt_name The name of the tracker object to retrieve.
Tracker The retrieved or created tracking object.push(commandArray)command array, which is simply a JavaScript array that
conforms to the following format. The first element of the array must be the name
of a tracker object method passed as a string. The rest of the array elements are the
values to be passed in as arguments to the function.
var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-65432-1']); _gaq.push(['_trackPageview']);
_gaq before Analytics has completely loaded. While Analytics is loading,
commands will be pushed/queued onto the array. When Analytics finishes loading,
it replaces the array with the _gaq object and executes
all the queued commands. Subsequent calls to _gaq.push resolve
to this function, which executes commands as they are pushed.var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-65432-1']); _gaq.push(['_trackPageview']); _gaq.push(['t2._setAccount', 'UA-65432-2']); _gaq.push(['t2._setDomainName', 'foo.com']); _gaq.push(['t2._trackPageview']);
''._gat and _gaq.var _gaq = _gaq || [];
_gaq.push(function() {
var tracker = _gat._getTracker('UA-65432-1');
tracker._trackPageview();
});
onclick="_gaq.push(['_trackEvent', 'name', value]);"
Lastly, instead of typing _gaq.push(...) for each command array, you
can push all of your commands at once. The following code demonstrates this technique.
See the Async Snippet
Usage Guide
for more details.
_gaq.push( ['_setAccount', 'UA-XXXXX-X'], ['_setDomainName', 'example.com'], ['_setCustomVar', 1, 'Section', 'Life & Style', 3], ['_trackPageview'] );
Array commandArray The command to be executed. One or more of these can be pushed in the same invocation.
Number The number of commands that failed to execute.