Configuration

The Analytics code can be configured to suite your tracking needs.

Most commonly developers need to set trackLocal to true if you want to test any GoSquared features in a local dev environment.

Options

OptionDescriptionTypeDefault
anonymizeIPSetting this value to true will prevent the visitors' IP address from being tracked.Booleanfalse
cookieDomainBy default, cookieDomain will be the current domain (including subdomain). This means that IDs will not be shared across subdomains. Set this to .your-domain.com to enable accurate cross-subdomain tracking.StringNot set (current domain)
useCookiesSet to false to disable usage of cookies in the tracker (for example, if your site is subject to strict cookie legislation). This will mean that certain parts of GoSquared will be inaccurate.Booleantrue
referrerUse this option to override the value of the page's referring URL. This is useful if you know the source of the pageview via another tracking system.Stringdocument.referrer
trackHashWhether to track hashes in the page URL, for example /home#my-hash will, by default, be tracked as /home.Booleanfalse
trackLocalWhether to track data and load Live Chat on local pages/sites (using the file:// protocol, or on localhost). This helps prevent local development from polluting your stats.Booleanfalse
trackParamsWhether to track URL querystring parameters, for example /home?my=query&string=true will be tracked as /home if this is set to false.Booleantrue

Add your desired configuration options after the main Analytics code snippet, below they are shown with their default values...

!function(g,s,q,r,d){r=g[r]=g[r]||function(){(r.q=r.q||[]).push(arguments)};
d=s.createElement(q);d.src='//d1l6p2sc9645hc.cloudfront.net/gosquared.js';q=
s.getElementsByTagName(q)[0];q.parentNode.insertBefore(d,q)}(window,document
,'script','_gs');

 _gs('GSN-123456-A');

 //Below the main Analytics code you can set config options

 _gs('set', 'anonymizeIP', false);
 _gs('set', 'cookieDomain', undefined);
 _gs('set', 'useCookies', true);
 _gs('set', 'referrer', document.referrer);
 _gs('set', 'trackHash', false);
 _gs('set', 'trackLocal', false);
 _gs('set', 'trackParams', true);

If you are using multiple project tokens on the same page you can scope a configuration option to a specific token.

//Assign names to your different tokens

_gs('project-token-1', 'mainSiteTracker');
_gs('project-token-2', 'webAppTracker');

//Then set the configuration option using the token name like this

_gs('mainSiteTracker.set', 'trackParams', true)

There may be some scenarios where you would like to ensure that the GoSquared snippet has loaded before you make a subsequent call. In this instance you have the ability to pass a callback in the script configuration.


_gs(function() {
      //perform additional request here.
});