Google Analytics

Tracking Code: The _gat Global Object

The _gat global object is used to create and retrieve tracker ojbects, from which all other methods are invoked. Therefore the methods in this list should be run only off a tracker object created using the _gat global variable. All other methods should be called using the _gaq global object for asynchronous tracking.

_gat Object Methods

Method Details


    Creates a tracker object for the given web property ID. If this method is called more than once for the same Analytic account ID, a new object is created for each invocation.


      String account The full web property ID (e.g. UA-65432-1) for the tracker object.


      Tracker The created tracking object.


    _createTracker(opt_account, opt_name)
    Creates a new tracker object and assigns it the given name. If no name is give, one will be generated. Tracker objects are stored under their names so they can be retrieved via _getTrackerByName. If two trackers are created with the same name, the second will overwrite the first and the first will no longer be retrieveable via _getTrackerByName.
    _gat._createTracker('UA-65432-2', 't2');


      String opt_account The full web property ID (e.g. UA-XXXXX-X) for the tracker object.
      String opt_name Optional name to store the tracker under. Use this name to retrieve the tracker via _getTrackerByName


      Tracker The created tracking object.


    Retrieves the tracker object with the given name. If no name is given, the default will be used, which is the empty string (''). If no tracker exists with the given name, a new tracker is created, assigned to that name and returned.


      String opt_name Optional name of the tracker to retrieve. Defaults to the empty string ('').


      Tracker The retrieved or created tracking object.



    Tells Google Analytics to anonymize the information sent by the tracker objects by removing the last octet of the IP address prior to its storage. Note that this will slightly reduce the accuracy of geographic reporting.

    When using this function to anonymize tracking, you must use the push function and properly associate the function with the tracker object, as illustrated below.

Async Snippet (recommended)
var _gaq = _gaq || [];
_gaq.push (['_setAccount', 'UA-XXXXXXX-YY']);
_gaq.push (['_gat._anonymizeIp']);
_gaq.push (['_trackPageview']);



    Configures Google Analytics to send all hits using SSL, even from insecure (HTTP) pages.

Async Snippet (recommended)

_gaq.push(['_setAccount', 'UA-12345-1']);
_gaq.push(['_gat._forceSSL']);       // Send all hits using SSL, even from insecure (HTTP) pages.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.