This reference contains all of the available methods that you can use to customize data configuration for Google Analytics reporting.
_addIgnoredOrganic(newIgnoredOrganicKeyword)_addIgnoredRef(newIgnoredReferrer)_addItem(orderId, sku, name, category, price, quantity)_addOrganic(newOrganicEngine, newOrganicKeyword)_addTrans(orderId, affiliation, total, tax, shipping, city, state, country)_clearIgnoredOrganic()_clearIgnoredRef()_clearOrganic()_cookiePathCopy(newPath)_createEventTracker(objName) deprecated_getAccount()_getClientInfo(1)_getDetectFlash(1)_getDetectTitle(1)_getLinkerUrl(targetUrl, useHash)_getLocalGifPath()_getServiceMode()_getVersion()_initData() deprecated_link(targetUrl, useHash)_linkByPost(formObject, useHash)_setAllowAnchor(enable)_setAllowHash(enable)_setAllowLinker(enable)_setCampContentKey(newCampContentKey)_setCampMediumKey(newCampMedKey)_setCampNameKey(newCampNameKey)_setCampNOKey(newCampNOKey)_setCampSourceKey(newCampSrcKey)_setCampTermKey(newCampTermKey)_setCampaignTrack(enable)_setClientInfo(enable)_setCookiePath(newCookiePath)_setCookieTimeout(newDefaultTimeout)_setDetectFlash(enable)_setDetectTitle(enable)_setDomainName(newDomainName)_setLocalGifPath(newLocalGifPath)_setLocalRemoteServerMode()_setLocalServerMode()_setRemoteServerMode()_setSampleRate(newRate)_setSessionTimeout(newTimeout)_setVar(newVal)_trackEvent(action, opt_label, opt_value) deprecated_trackEvent(category, action, opt_label, opt_value)_trackPageview(opt_pageURL)_trackTrans()_addIgnoredOrganic(newIgnoredOrganicKeyword)pageTracker._addIgnoredOrganic("www.mydomainname.com");
String newIgnoredOrganicKeyword Keyword search terms to treat as direct traffic.
_addIgnoredRef(newIgnoredReferrer)pageTracker._addIgnoredRef("www.sister-site.com");
String newIgnoredReferrer Referring site to exclude.
_addItem(orderId, sku, name, category, price, quantity)Use this method
to track items purchased by visitors to your ecommerce site. This method
tracks individual items by the required sku parameter. However, it associates the item to the parent transaction object via the orderId argument. Arguments for this method are matched by position, so be sure to supply all parameters, even if some of them have an empty value.
This method performs no additional ecommerce calculations, such
as quantity calculations. Therefore, if the item being added is a duplicate
(by SKU) of an existing item for that session, then the old information is
replaced with the new. Additionally, while the _addItem() method does not enforce the creation of a
parent transaction object, you should set this up explicitly
in your transaction tracking code. If no parent transaction object exists
for an added item, the item is attached to an empty transaction object instead. In this case, your reports will show products by SKU that are not associated with any transaction.
pageTracker._addItem(
"1234", // order ID - necessary to associate item with transaction
"DD44", // SKU/code - required
"T-Shirt", // product name
"Olive Medium", // category or variation
"11.99", // unit price - required
"1" // quantity - required
);
String orderId Order ID of the transaction to associate with item. String sku Required. Item's SKU code. String name Product name. String category Product category. String price Required. Product price. String quantity Required. Purchase quantity. _addOrganic(newOrganicEngine, newOrganicKeyword)String newOrganicEngine Engine for new organic source.
String newOrganicKeyword Keyword name for new organic source.
_addTrans(orderId, affiliation, total, tax, shipping, city, state, country)_addItem(),
this method handles only transaction tracking and provides no additional ecommerce
functionality. Therefore, if the transaction is a duplicate of an existing
transaction for that session, the old transaction values are over-written with the
new transaction values. Arguments for this method are matched by position, so be sure to supply all parameters, even if some of them have an empty value. pageTracker._addTrans(
"1234", // order ID - required
"Womens Apparel", // affiliation or store name
"11.99", // total - required
"1.29", // tax
"15.00", // shipping
"San Jose", // city
"California", // state or province
"USA" // country
);
String orderId Required. Internal unique order id number for this transaction. String affiliation Partner or store affiliation (undefined
if absent).String total Required. Total dollar amount of the transaction. String tax Tax amount of the transaction. String shipping Shipping charge for the transaction. String city City to associate with transaction. String state State to associate with transaction. String country Country to associate with transaction. _gat.GA_EComm_.Transactions_ The transaction object that was
created or modified. _clearIgnoredOrganic()_clearIgnoredRef()_clearOrganic()_cookiePathCopy(newPath)var pageTracker = _gat._getTracker("UA-12345-1");
pageTracker._trackPageview();
pageTracker._cookiePathCopy("/newSubDirectory/");
String newPath New path to store GATC cookies under.
_createEventTracker(objName) Deprecated. Use _trackEvent() instead.
var videoTracker = pageTracker._createEventTracker("Videos");
String objName The name of the tracked object.
_gat.GA_EventTracker_ A new event tracker instance.
_getAccount()String Account ID this tracker object is instantiated with.
_getClientInfo(1)_setClientInfo() for more information.Number 1 if enabled, 0 if disabled.
_getDetectFlash(1)_setDetectFlash() for more
information.Number 1 if enabled, 0 if disabled.
_getDetectTitle(1)Number 1 if enabled, 0 if disabled.
_getLinkerUrl(targetUrl, useHash)_setDomainName() and _setAllowLinker()
methods to enable cross-domain user tracking specifically for iFrames and links that open in a new window. This method returns a string of all the cookie data from the initing link by appending it to the URL parameter. This can then be passed on to a another site or iFrame.
pageTracker._getLinkerUrl("http://www.my-example-iframecontent.com/");
pageTracker._setAllowLinker(true);) in
order for link to work properly.
String targetUrl URL of target site to send cookie values to. String useHash Set to true for passing tracking code variables by
using the # anchortag separator rather than the default ? query string
separator.
_getLocalGifPath()_setLocalGifPath() for more information.String Path to GIF file on the local server.
_getServiceMode()_setLocalGifPath()),
1 for remote mode (send data to Google Analytics backend server), or 2
for both local and remote mode.Number Server operation mode.
_getVersion()String GATC version number.
_initData()Deprecated. initData() now executes automatically in the ga.js tracking code.var pageTracker = _gat._getTracker("UA-12345-1");
pageTracker._initData();
pageTracker._trackPageview();
_link(targetUrl, useHash)_setDomainName() and _setAllowLinker()
methods to enable cross-domain user tracking. The _link() method passes the cookies
from this site to another via URL parameters (HTTP GET). It also changes the document.location and redirects
the user to the new URL.
<a href="http://www.newsite.com" onclick="pageTracker._link('http://www.newsite.com');return false;">Go to our sister site</a>
pageTracker._setAllowLinker(true);) in
order for link to work properly.
String targetUrl URL of target site to send cookie values to.
String useHash Set to true for passing tracking code variables by
using the # anchortag separator rather than the default ? query string
separator. (Currently this behavior is for internal Google properties only.)
_linkByPost(formObject, useHash)_setDomainName() and _setAllowLinker()
methods to enable cross-domain user tracking. The _linkByPost() method passes
the cookies from the referring form to another site in a string appended to the action value of
the form (HTTP POST). This method is typically used when tracking user behavior from one site to
a 3rd-party shopping cart site, but can also be used to send cookie data to other domains in pop-ups
or in iFrames.
<form action="http://www.shoppingcartsite.com/myService/formProcessor.php"
name="f" method="post" onsubmit="pageTracker._linkByPost(this)">
. . .
</form>
_setAllowLinker() must be set to true on the destination web page
in order for linking to work.
HTMLFormElement formObject Form object encapsulating the POST
request.
String useHash Set to true for passing tracking code variables by
using the # anchortag separator rather than the default ? query string
separator.
_setAllowAnchor(enable)http://mysite.net/index.html?source=In+House#method=email#offer_type=Fall+email+offers pageTracker._setAllowAnchor(true);
Boolean enable If this parameter is set to true, then campaign will
use anchors. Else, campaign will use search strings.
_setAllowHash(enable)example1.example.com and example2.example.com,
and you want to track user behavior across both of these sub-domains,
you would turn off domain hashing so that the cookie integrity check
will not reject a user cookie coming from one domain to another. Additionally,
you can turn this feature off to optimize per-page tracking performance.Boolean enable If this parameter is set to true, then domain hashing
is enabled. Else, domain hashing is disabled. True by default.
_setAllowLinker(enable)_link(), _linkByPost(), and _setDomainName() methods
to enable cross-domain tracking. Use the _setAllowLinker method on the target site, so that the target site uses the cookie data in the URL parameter, instead of the standard session logic.
pageTracker._setAllowLinker(true);
Boolean enable If this parameter is set to true, then linker is
enabled. Else, linker is disabled.
_setCampContentKey(newCampContentKey)http://mysite.net/index.html?source=giganoshopper.com&method=referral&offer_type=Christmas+specials&description=Garden+gloves
pageTracker._setCampContentKey("description");
String newCampContentKey New campaign content key to set.
_setCampMediumKey(newCampMedKey)http://mysite.net/index.html?source=giganoshopper.com&method=ad&offer_type=Christmas+specials&description=Garden+gloves
pageTracker._setCampMediumKey("method");
String newCampMedKey Campaign medium key to set.
_setCampNameKey(newCampNameKey)http://mysite.net/index.html?source=In+House&method=email&offer_type=Fall+email+offers
pageTracker._setCampNameKey("offer_type");
String newCampNameKey Campaign name key.
_setCampNOKey(newCampNOKey)http://mysite.net/index.html?source=giganoshopper.com&method=referral&offer_type=Christmas+specials&description=Garden+gloves&noo=1234
pageTracker._setCampNOKey("noo");
String newCampNOKey Campaign no-override key to set.
_setCampSourceKey(newCampSrcKey)http://mysite.net/index.html?source=giganoshopper.com&method=referral&offer_type=Christmas+specials&description=Garden+gloves
pageTracker._setCampSourceKey("source");
String newCampSrcKey Campaign source key to set.
_setCampTermKey(newCampTermKey)http://mysite.net/index.html?source=weSearch4You.com&method=paidSearchAd&offer_type=Christmas+specials&description=Garden+gloves&term=garden+tools
pageTracker._setCampTermKey("term");
String newCampTermKey Term key to set.
_setCampaignTrack(enable)Boolean enable True by default, which enables campaign
tracking. If set to false, campaign tracking is disabled.
_setClientInfo(enable)Boolean enable Defaults to true, and browser
tracking is enabled. If set to false, browser tracking is disabled.
_setCookiePath(newCookiePath)pageTracker._setCookiePath("/~username/");
pageTracker._setCookiePath("/myBlogDirectory/");
String newCookiePath New cookie path to set.
_setCookieTimeout(newDefaultTimeout)pageTracker._setCookieTimeout("3152600"); //number of seconds in 1 year
String newDefaultTimeout New default cookie expiration time to set. Pass in as a string and it is converted to an integer.
_setDetectFlash(enable)Boolean enable Default is true and Flash
detection is enabled. False disables Flash detection..
_setDetectTitle(enable)Boolean enable Defaults to true, and title
detection is enabled. If set to false, title detection is disabled.
_setDomainName(newDomainName)
Sets the domain name for cookies. There are three modes to this method: ("auto" | "none" | [domain]). By default, the method is set to auto,
which attempts to resolve the domain name based on the location object
in the DOM.
Set this method explicitly to your domain name if you want to track visitor behavior
across sub-domains in the same profile. For example, if you have two sub-domains that you want to track in the same profile: petstore.example.com and fishstore.example.com, you would set the
domain name in each of these sites as follows:
pageTracker._setDomainName(".example.com");
As a best-practice method, you should use a leading "." in front of your domain name, as illustrated above. The leading period ensures that the same cookies will be read and written across all sub-domains of the specified domain.
If you do not use the leading "." when supplying a primary domain—as in the example above—the browser automatically sets the domain name with a leading period so that cookies are available to petstore.example.com and fishstore.example.com. However, if you want tracking across lower-level sub-domains:
dogs.petstore.example.com and cats.petstore.example.com, a leading period is required. If you do not use the leading period in this type of setup, the cookies will not be available to the lower-level domains of example.com (e.g. dogs.petstore.example.com).
For this reason, the most reliable sub-domain tracking is achieved by consistently using the leading "." and in calling _setDomainName() in all domains/sub-domains that you want to track as a single entity. This is because the Analytics creates an encoded value of the domain specified by the parameter passed into _setDomainName(), and if the parameter is not identical across all domains, then different encoded values will be created, causing conflicts and unexpected reporting behaviors.
Set this method to none in the following two situations:
_setAllowLinker() and _linkpageTracker._setDomainName("none");
String newDomainName New default domain name to set.
_setLocalGifPath(newLocalGifPath)_setLocalServerMode() and
_setLocalRemoteServerMode() methods to determine
the path to the local server itself.String newLocalGifPath Path to GIF file on the local server.
_setLocalRemoteServerMode()_setLocalGifPath()._setLocalServerMode()_setLocalGifPath()._setRemoteServerMode()_setSampleRate(newRate)pageTracker._setSampleRate("80"); //sets sampling rate to 80 percent
String newRate New sample rate to set. Provide a numeric string as a whole percentage.
_setSessionTimeout(newTimeout)String newTimeout New session timeout to set in seconds.
_setVar(newVal)String newVal New user defined value to set.
_trackEvent(action, opt_label, opt_value) Deprecated. Use _trackEvent(category, action, label, value) instead.
Constructs and sends the event tracking call to GATC via the event tracking object.
String eventType The type name for the event.
String opt_label An optional descriptor for the event.
Int opt_value An optional value to be aggregated with
the event.
Boolean whether the event was successfully sent.
_trackEvent(category, action, opt_label, opt_value)
String category The general event category (e.g. "Videos").
String action The action for the event (e.g. "Play").
String opt_label An optional descriptor for the event.
Int opt_value An optional value to be aggregated with
Boolean whether the event was successfully sent.
_trackPageview(opt_pageURL)document.cookie.
It also updates or creates cookies as necessary, then writes them back to the
document object. Gathers all the appropriate metrics to send to the
UCFE (Urchin Collector Front-end).var pageTracker = _gat._getTracker("UA-12345-1");
pageTracker._trackPageview("/home/landingPage");
String opt_pageURL Optional parameter to indicate what page
URL to track metrics under. When using this option, use a beginning
slash (/) to indicate the page URL.
_trackTrans()_trackPageview(), and used in conjunction with the
_addItem() and addTrans() methods. It should be called after
items and transaction elements have been set up.var pageTracker = _gat._getTracker("UA-12345-1");
pageTracker._trackPageview();
pageTracker._addTrans(
"1234", // order ID - required
"Womens Apparel", // affiliation or store name
"11.99", // total - required
"1.29", // tax
"15.00", // shipping
"San Jose", // city
"California", // state or province
"USA" // country
);
pageTracker._addItem(
"1234", // order ID - necessary to associate item with transaction
"DD44", // SKU/code - required
"T-Shirt", // product name
"Olive Medium", // category or variation
"11.99", // unit price - required
"1" // quantity - required
);
pageTracker._trackTrans();