Show Menu

JavaScript implementation overview

To begin using Analytics, data must be sent to a report suite to display in reporting.
The easiest and recommended way to send data to Analytics is by using Launch . However, in some cases, you might want to implement Analytics using the older JavaScript method.
This section describes the legacy method of implementing Analytics. All Analytics customers have access to Launch , which is the standard method to deploy Experience Cloud tags.

Implementation Steps

To successfully implement a page with code to collect data, you must have access to your hosting servers to upload new content to your website. It is also useful to have an existing site to implement code.
The following steps walk you through a basic Analytics implementation.
1. Download AppMeasurement for JavaScript and the ID service.
Log in to Analytics via the Experience Cloud. The download file is available at Analytics > Admin > Code Manager. This download zip contains several files. AppMeasurement.js and VisitorAPI.js are the relevant files when implementing Analytics.
2. Set up the Identity Service. (Formerly Visitor ID service)
3. Update AppMeasurement.js .
Copy the example AppMeasurement.js code and paste it at the beginning of your AppMeasurement.js file. At a minimum, update the following variables:
  • s.account="INSERT-RSID-HERE"
  • s.trackingServer="INSERT-TRACKING-SERVER-HERE"
  • s.visitorNamespace = "INSERT-NAMESPACE-HERE"
  • s.visitor = Visitor.getInstance("INSERT-MCORG-ID-HERE")
See Correctly populate the trackingServer and trackingServerSecure variable or contact Client Care if you are unsure about any of these values. If they are not set correctly, data will not be collected by your implementation.
4. Host AppMeasurement.js and VisitorAPI.js .
These core JavaScript files must be hosted on a web server that is accessible to all pages on your site. You need the path to these files in the next step.
5. Reference AppMeasurement.js and VisitorAPI.js on all site pages.
  • Include the Visitor ID Service by adding the following line of code in the head or body tag on each page. ( VisitorAPI.js must be included before AppMeasurement.js ).
    script language="JavaScript" type="text/javascript" src="https://INSERT-DOMAIN-AND-PATH-TO-CODE-HERE/VisitorAPI.js"
  • Include AppMeasurement for JavaScript by adding the following line of code in the head or body tag on each page:
    script language="JavaScript" type="text/javascript" src="https://INSERT-DOMAIN-AND-PATH-TO-CODE-HERE/AppMeasurement.js"
6. Update and deploy page code.
Copy the Example Page Code and paste it just after the opening body tag on each page you want to track. At a minimum, update the following variables:
  • var s=s_gi("INSERT-RSID-HERE")
  • s.pageName="INSERT-NAME-HERE" (for example, s.pageName=document.title)
7. Use the Experience Cloud Debugger to verify that data is being sent.
Install the Experience Cloud Debugger . After it is installed, load a page where you have deployed page code and then open the debugger. The debugger displays details about the collection data that was sent.


The JavaScript file is cached in the visitor's browser after it is initially loaded, and is typically downloaded no more than once per session. The file is not downloaded on each page, even though it is used by every page on the site. On most websites, users average more than a few page views per session, so transferring JavaScript that is used multiple times into this file can result in less overall downloaded data.

JavaScript for AppMeasurement Compression

If you are concerned about page weight (size) of H Code (AppMeasurement for JavaScript 1.0 is pre-compressed), Adobe recommends that you consider compressing the file using GZIP. GZIP is supported by all major browsers and offers better performance than JavaScript compression to compress and decompress the core s_code.js JavaScript file.
The following links help explain how you can use GZIP functionality on your site to handle compression of the s_code.js JavaScript code: