Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

How to implement multiple instance of Adobe Analytics with one library

Alexis Cazes edited this page Jun 10, 2016 · 2 revisions

Step 1: Download the Adobe Analytics library

  • Go to Adobe Analytics V15
  • Go to Admin >> Code Manager
  • Download the latest Javascript (New) aka AppMeasurement.js

Step 2: Create an Adobe Analytics object for each instance

In Appmeasurement.js file add the following code for each instance of Adobe Analytics

/*
** First Instance of Adobe Analytics 
*/
/************************** CONFIG SECTION START**************************/
s = new AppMeasurement()
//Add your Report suite ID
s.account="[REPORT SUITE ID]"
//Instantiate Visitor ID services
s.visitor = Visitor.getInstance("[MARKETING CLOUD ORG ID]");

/* You may add or alter any code config here. */
/* Link Tracking Config */
s.trackDownloadLinks=true
s.trackExternalLinks=true
s.linkDownloadFileTypes="exe,zip,wav,mp3,mov,mpg,avi,wmv,pdf,doc,docx,xls,xlsx,ppt,pptx"
s.linkInternalFilters="javascript:" //optional: add your internal domain here
s.linkLeaveQueryString=false
s.linkTrackVars="None"
s.linkTrackEvents="None"

/* doPlugins START */
s.usePlugins=true
function s_doPlugins(s) {
	/* Set custom code that will be ran on each s.t() and s.tl() */
	//Capture Marketing Cloud Visitor ID details
	s.prop1 = s.eVar1 = (typeof(Visitor) != "undefined" ? "VisitorAPI Present" : "VisitorAPI Missing");
}
s.doPlugins=s_doPlugins 
/* doPlugins END */

//Enable Debug Tracking -- Displays image request in console
s.debugTracking=true

//Tracking server and Namespace config : https://helpx.adobe.com/analytics/kb/determining-data-center.html
s.trackingServer="[TRACKING SERVER]"
s.visitorNamespace="[TRACKING DOMAIN]"

/*
** Second Instance of Adobe Analytics 
*/
/************************** CONFIG SECTION START**************************/
s2 = new AppMeasurement()
//Add your Report suite ID
s2.account="[REPORT SUITE ID]"
//Instantiate Visitor ID services
s2.visitor = Visitor.getInstance("[MARKETING CLOUD ORG ID]");

/* You may add or alter any code config here. */
/* Link Tracking Config */
s2.trackDownloadLinks=true
s2.trackExternalLinks=true
s2.linkDownloadFileTypes="exe,zip,wav,mp3,mov,mpg,avi,wmv,pdf,doc,docx,xls,xlsx,ppt,pptx"
s2.linkInternalFilters="javascript:" //optional: add your internal domain here
s2.linkLeaveQueryString=false
s2.linkTrackVars="None"
s2.linkTrackEvents="None"

/* doPlugins START */
s2.usePlugins=true
function s2_doPlugins(s) {
	/* Set custom code that will be ran on each s.t() and s.tl() */
	//Capture Marketing Cloud Visitor ID details
	s2.prop1 = s2.eVar1 = (typeof(Visitor) != "undefined" ? "VisitorAPI Present" : "VisitorAPI Missing");
}
s2.doPlugins=s2_doPlugins 
/* doPlugins END */

//Enable Debug Tracking -- Displays image request in console
s2.debugTracking=true

//Tracking server and Namespace config : https://helpx.adobe.com/analytics/kb/determining-data-center.html
s2.trackingServer="[TRACKING SERVER]"
s2.visitorNamespace="[TRACKING DOMAIN]"

You will notice that each instance of Adobe Analytics use a different object name. Each Adobe Analytics instance is independent of the other one It is perfect if you have to do multi company Adobe Analytics tagging on one specific web page. This solution allow you to only reference the main library once.

Step 3: Call s.t() and s.tl() for each instance of Adobe Analytics when needed

Once all of the variables for the specific instance are configured simply call:

//Adobe Analytics instance 1: s
//For a pageview
s.t();
//For an action tracking (link, button click)
s.tl(this, "o", "Name of action");

//Adobe Analytics instance 2: s2
//For a pageview
s2.t();
//For an action tracking (link, button click)
s2.tl(this, "o", "Name of action");
Clone this wiki locally