This reference describes the methods that you use for customizing how Google Analytics reporting works across domains, across different hosts, or within sub-directories of a website.
_cookiePathCopy(newPath)_link(targetUrl, useHash)_linkByPost(formObject, useHash)_setAllowHash(enable)_setAllowLinker(enable)_setCookiePath(newCookiePath)_setDomainName(newDomainName)_cookiePathCopy(newPath)_initData() must be called).var pageTracker = _gat._getTracker("UA-12345-1");
pageTracker._initData();
pageTracker._trackPageview();
pageTracker._cookiePathCopy("/newSubDirectory/");
String newPath New path to store GATC cookies under.
_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.
_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.
_setCampaignTrack(enable)Boolean enable True by default, which enables campaign
tracking. If set to false, campaign tracking is disabled.
_setAllowLinker(enable)_link(),
_linkByPost(), and _setDomainName() methods
to enable cross-domain tracking.pageTracker._setAllowLinker(true);
Boolean enable If this parameter is set to true, then linker is
enabled. Else, linker is disabled.
_setCookiePath(newCookiePath)pageTracker._setCookiePath("/~username/");
pageTracker._setCookiePath("/myBlogDirectory/");
String newCookiePath New cookie path to set.
_setDomainName(newDomainName)("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. server1.example.com and server2.example.com, you would set the
domain name as follows:pageTracker._setDomainName(".example.com");_setAllowLinker()
and _linkpageTracker._setDomainName("none");
String newDomainName New default domain name to set.