Multiple Tracking Codes

Multiple tracking codes are useful or segmenting your tracking data into different projects, allowing you to have separate dashboards for different sections of your site or web app. Simply include the project tokens for different projects on each page. You can either track all events, pageviews and people on all the sites, or selectively track different activity on the different sites.

We at GoSquared use this functionality ourselves to understand how our entire platform is performing as a whole as well as segmenting areas (such as this documentation area) to see how specific areas are performing over time.

Multiple tracking codes are easy to install, simply call _gs('GSN-123456-A') again with the other project token. This is primarily useful for segmenting tracking data.

// tracks a pageview on each of three sites

// everything from here onwards is tracked in all three projects. e.g:
_gs('event', 'Some Event Name');

You can also assign names to different tokens, and then scope actions to a specific project:

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

// identify a user only for project-token-1:
_gs('mainSiteTracker.identify', {
  id: 'only-on-main-site',
  email: ''

// track an event only under project-token-2:
_gs('webAppTracker.event', 'Some Event Name');

All of the commands you can call with _gs can be restricted to an individual project by prefixing the corresponding trackerName. to the first argument.