The Adobe Analytics framework determines the information that is tracked with Adobe Analytics. To customize the default framework, you use javascript to add custom tracking, integrate Adobe Analytics plugins, and change general settings within the framework used for tracking.
When a page is associated with a Adobe Analytics framework, and the page includes references to the Analytics module, a analytics.sitecatalyst.js file is automatically generated for the page.
The javascript in the page creates an s_gi
object (that the s_code.js Adobe Analytics library defines) and assigns values to its properties. The name of the object instance is s
. The code examples that are presented in this section makes several references to this s
variable.
The following example code is similar to the code in an analytics.sitecatalyst.js file:
var s_account = "my_sitecatalyst_account";
var s = s_gi(s_account);
s.fpCookieDomainPeriods = "3";
s.currencyCode= 'USD';
s.trackInlineStats= true;
s.linkTrackVars= 'None';
s.charSet= 'UTF-8';
s.linkLeaveQueryString= false;
s.linkExternalFilters= '';
s.linkTrackEvents= 'None';
s.trackExternalLinks= true;
s.linkDownloadFileTypes= 'exe,zip,wav,mp3,mov,mpg,avi,wmv,doc,pdf,xls';
s.linkInternalFilters= 'javascript:,'+window.location.hostname;
s.trackDownloadLinks= true;
s.visitorNamespace = "mynamespace";
s.trackingServer = "xxxxxxx.net";
s.trackingServerSecure = "xxxxxxx.net";
/* Plugin Config */
/*
s.usePlugins=false;
function s_doPlugins(s) {
//add your custom plugin code here
}
s.doPlugins=s_doPlugins;
*/
When you use custom javascript code to customize the framework, you alter the content of this file.
There are a number of predefined variables within Adobe Analytics that are configurable on a framework. The charset, cookieLifetime, currencyCode and trackInlineStats variables are included in the General Analytics Settings list by default.
You can add variable names and values to the list. These predefined variables and any variables that you add are used to configure the properties of the s
object in the analytics.sitecatalyst.js file. The following example shows how the added prop10
property of value CONSTANT
is represented in the javascript code:
var s_account = "my_sitecatalyst_account";
var s = s_gi(s_account);
s.fpCookieDomainPeriods = "3";
s.currencyCode= 'USD';
s.trackInlineStats= true;
s.linkTrackVars= 'None';
s.charSet= 'UTF-8';
s.linkLeaveQueryString= false;
s.linkExternalFilters= '';
s.linkTrackEvents= 'None';
s.trackExternalLinks= true;
s.linkDownloadFileTypes= 'exe,zip,wav,mp3,mov,mpg,avi,wmv,doc,pdf,xls';
s.prop10= 'CONSTANT';
s.linkInternalFilters= 'javascript:,'+window.location.hostname;
s.trackDownloadLinks= true;
s.visitorNamespace = "mynamespace";
s.trackingServer = "xxxxxxx.net";
s.trackingServerSecure = "xxxxxxx.net";
Use the following procedure to add variables to the list:
On your Adobe Analytics framework page, expand the General Analytics Settings area.
Below the list of variables, click Add Item to add a new variable to the list.
In the left-hand cell, enter a name for the variable, for example prop10
.
In the right-hand column, enter a value for the variable, for example CONSTANT
.
To remove a variable, click the (-) button next to the variable.
When entering variables and values, make sure they are correctly formatted and spelled, or the calls will not be sent with the correct value/variable pair. Misspelled variables and values can even prevent calls from occurring.
Consult with your Adobe Analytics representative to make sure these variables are correctly set.
Some of the variables in this list are mandatory in order for Adobe Analytics calls to function correctly, (e.g. currencyCode, charSet)
So, even if they are removed from the framework itself, they will still be attached with a default value when the Adobe Analytics call is made.
The free-from javascript box in the General Analytics Settings area enables you to add custom code to a Adobe Analytics framework.
The code that you add is appended to the analytics.sitecatalyst.js file. Therefore, you can access the s
variable, which is an instance of the s_gi
javascript object that is defined in s_code.js
. For example, adding the following code is equivalent to adding a variable named prop10
of value CONSTANT
, which is the example in the previous section:
s.prop10= 'CONSTANT';
The code in the analytics.sitecatalyst.js file (which includes the content of the Adobe Analytics s-code.js
file) contains the following code:
if (s.usePlugins) s.doPlugins(s)
The following procedure demonstrates how to use the javascript box to customize Adobe Analytics tracking. If your javascript needs to use Adobe Analytics plugins, integrate them into AEM.
Add the following javascript code to the box so that s.doPlugins
is executed:
s.usePlugins=true;
function s_doPlugins(s) {
//add your custom code here
}
s.doPlugins=s_doPlugins;
This code is necessary if you want to send variables in a Adobe Analytics call that have been customized in some way that cannot be done through the basic drag&drop interface OR through inline javascript in Adobe Analytics View.
If the custom variables are outside of the s_doPlugins function they will be sent as *undefined *in the Adobe Analytics call
Add your javascript code in the s_doPlugins function.
The following example concatenates the data captured on a page in hierarchical order, using a common separator of “|”.
A Adobe Analytics framework has the following configruations:
The prop2
Adobe Analytics variable is mapped to the pagedata.sitesection
site property.
The prop3
Adobe Analytics variable is mapped to the pagedata.subsection
site property.
The following code is added to the free-from javascript box:
s.usePlugins=true;
function s_doPlugins(s) {
s.prop1 = s.prop2+'|'+s.prop3;
}
s.doPlugins=s_doPlugins;
When the webpage that uses the framework is visited (or, in edit mode the page is reloaded or previewed), the calls to Adobe Analytics are performed.
For example, the following values are generated in Adobe Analytics:
Provide custom javascript code that is integrated into all Adobe Analytics frameworks. When a page’s Adobe Analytics framework contains no custom free-form javascript, the javascript that the /libs/cq/analytics/components/sitecatalyst/config.js.jsp script generates is appended to the analytics.sitecatalyst.js file. By default, the script has no effect because it is commented out. The code also sets s.usePlugins
to false
:
/* Plugin Config */
/*
s.usePlugins=false;
function s_doPlugins(s) {
//add your custom plugin code here
}
s.doPlugins=s_doPlugins;
*/
Code in the analytics.sitecatalyst.js file (which includes the content of the Adobe Analytics s_code.js file) contains the following code:
if (s.usePlugins) s.doPlugins(s)
Therefore, your javascript should set s.usePlugins
to true
so that any code in the s_doPlugins
function is executed. To customize the code, overlay the config.js.jsp file with one that uses your own javascript. If your javascript needs to use Adobe Analytics plugins, integrate them into AEM.
Do not edit the /libs/cq/analytics/components/sitecatalyst/config.js.jsp file. Certain AEM upgrade or maintenance tasks can re-install the original file, removing your changes.
In CRXDE Lite, create the /apps/cq/analytics/components folder structure:
cq
as the folder name, and click OK.analytics
and components
folders.Right-click the components
folder that you just created and click Create > Create Component. Specify the following property values:
sitecatalyst
sitecatalyst
/libs/cq/analytics/components/sitecatalyst
hidden
Click Next repeatedly until the OK button is enabled, and then click OK.
The sitecatalyst component contains the automatically-created sitecatalyst.jsp file.
Right-click the sitecatalyst.jsp file and click Delete.
Right-click the sitecatalyst component and click Create > Create File. Specify the name config.js.jsp
and then click OK.
The config.js.jsp file opens automatically for editing.
Add the following text to the file, and then click Save All:
<%@page session="true"%>
/* Plugin Config */
s.usePlugins=true;
function s_doPlugins(s) {
//add your custom plugin code here
}
s.doPlugins=s_doPlugins;
The javascript code that the /apps/cq/analytics/components/sitecatalyst/config.js.jsp script generates is now inserted into the analytics.sitecatalyst.js file for all pages that use a Adobe Analytics framework.
Add the javascript code that you want to execute in the s_doPlugins
function, and then click Save All.
If any text is present in the free-form javascript of a page’s framework (even only whitespace), config.js.jsp is ignored.
Obtain the javascript code for Adobe Analytics plugins and integrate them into your Adobe Analytics framework in AEM. Add the code to a client library folder of the category sitecatalyst.plugins
so that they are available to your custom javascript code.
For example, if you integrate the getQueryParams
plugin, you can call the plugin from the s_doPlugins
function of your custom javascript. The following example code sends the query string in “pid” from the referrer’s URL as eVar1, when a Adobe Analytics call is triggered.
s.usePlugins=true;
function s_doPlugins(s) {
// take the query string from the referrer
s.eVar1=s.getQueryParam('pid','',document.referrer);
}
s.doPlugins=s_doPlugins;
AEM installs the following Adobe Analytics plugins, so that they are available by default:
The /libs/cq/analytics/clientlibs/sitecatalyst/plugins client library folder includes these plugins in the sitecatalyst.plugins category.
Create a new client library folder for your plugins. Do not add plugins to the /libs/cq/analytics/clientlibs/sitecatalyst/plugins
folder. This practice ensures that your contribution to the sitecatalyst.plugins
category are not overwritten during AEM re-installs or upgrade tasks.
Use the following procedure to create the client library folder for your plugins. You only need to peform this procedure once. To add a plugin to the client library folder, use the subsequent procedure.
In a web browser, open CRXDE Lite. (http://localhost:4502/crx/de)
Right-click the /apps/my-app/clientlibs folder and click Create > Create Node. Enter the following property values and then click OK:
Name: A name for your client library folder, such as my-plugins
Type: cq:ClientLibraryFolder
Select the client library folder that you just created and use the bottom right-hand property bar to add the following property:
Click OK in the Edit window to confirm the property value.
Right-click the client library folder that you just created and click Create > Create File. For the file name type js.txt, and then click OK.
Click Save All.
Use the following procedure to obtain the plugin code, store the code in the AEM repository, and add the code to your client library folder.
Log in to sc.omniture.com using your Adobe Analytics account.
On the landing page go to Help > Help Home.
In the table of contents on the left side, click Implementation Plug-ins.
Click the link to the plugin that you want to add and when the page opens, locate the javascript source code for the plugin, then select the code and copy it.
Right-click your client library folder, and click Create > Create File. For the file name, type the name of the plugin that you are integrating followed by .js, and then click OK. For example, if you are integrating the getQueryParam plugin, name the file getQueryParam.js.
When you create the file, it opens for editing.
Paste the plugin javascript code into the file, click Save All, and then close the file.
Open the js.txt file from your client library folder.
In a new line, add the name of the file that contains the plugin, for example getQueryParam.js. Then, click Save All and close the file.
When using plugins, make sure to integrate any supporting plugins as well, otherwise the plugin javascript will not recognize the calls that it makes to the functions in the supporting plugin. For example, the getPreviousValue() plugin requires the split() plugin to function correctly.
The name of the support plugin needs to be added to js.txt as well.