Implement the Experience Cloud ID Service for Analytics

These instructions are for Analytics customers who want to use the Experience Cloud ID service and do not use Dynamic Tag Management (DTM). However, we strongly recommend that you use DTM to implement the ID service. DTM streamlines the implementation workflow and automatically ensures the correct code placement and sequencing.

Important:
  • Read the requirements before you begin.
  • Configure and test this code in a development environment before implementing it in production.

Step 1: Download the ID Service Code

The ID Service requires the VisitorAPI.js code library. To download this code library:

  1. Go to Admin > Code Manager.
  2. In Code Manager, click either JavaScript (New) or JavaScript (Legacy). This downloads compressed code libraries.
  3. Decompress the code file and open the VisitorAPI.js file.

Step 2. Add the Visitor.getInstance Function to the ID Service Code

Important:
  • Previous versions of the ID service API placed this function in a different location and required a different syntax. If you are migrating from a version prior to version 1.4, note the new placement and syntax documented here.
  • Code in ALL CAPS is a placeholder for actual values. Replace this text with your Organization ID, tracking server URL, or other named value.

Part 1: Copy the Visitor.getInstance function below

var visitor = Visitor.getInstance("INSERT-MARKETING-CLOUD-ORGANIZATION-ID-HERE", {
     trackingServer: "INSERT-TRACKING-SERVER-HERE", // same as s.trackingServer
     trackingServerSecure: "INSERT-SECURE-TRACKING-SERVER-HERE", // same as s.trackingServerSecure

     // To enable CNAME support, add the following configuration variables
     // If you are not using CNAME, DO NOT include these variables
     marketingCloudServer: "INSERT-TRACKING-SERVER-HERE",
     marketingCloudServerSecure: "INSERT-SECURE-TRACKING-SERVER-HERE" // same as s.trackingServerSecure
});

Part 2: Add function code to the VisitorAPI.js file

Place the Visitor.getInstance function at the end of the file after the code block. Your edited file should look like this:

/*
========== DO NOT ALTER ANYTHING BELOW THIS LINE ==========
Version and copyright section
*/

// Visitor API code library section

// Put Visitor.getInstance at the end of the file, after the code library



var visitor = Visitor.getInstance("INSERT-MARKETING-CLOUD-ORGANIZATION-ID-HERE", {
     trackingServer: "INSERT-TRACKING-SERVER-HERE", // same as s.trackingServer
     trackingServerSecure: "INSERT-SECURE-TRACKING-SERVER-HERE", // same as s.trackingServerSecure

     // To enable CNAME support, add the following configuration variables
     // If you are not using CNAME, DO NOT include these variables
     marketingCloudServer: "INSERT-TRACKING-SERVER-HERE",
     marketingCloudServerSecure: "INSERT-SECURE-TRACKING-SERVER-HERE" // same as s.trackingServerSecure
});

Step 3: Add Your Experience Cloud Organization ID to Visitor.getInstance

In the Visitor.getInstance function, replace INSERT-MARKETING-CLOUD-ORGANIZATION ID-HERE with your Experience Cloud organization ID. If you do not know your organization ID, you can find it on the Experience Cloud administration page. See also, Administration - Core Services. Your edited function could look similar to the example below.

var visitor = Visitor.getInstance("1234567ABC@AdobeOrg", { ...

Important: Do not change the case of the characters in your organization ID. The ID is case-sensitive and must be used exactly as provided.

Step 4: Add Your Tracking Servers to Visitor.getInstance

Tracking servers are used for Analytics data collection.

Part 1: Find your tracking server URLs

Check your s_code.js or AppMeasurement.js files to find the tracking server URLs. You'll want the URLs specified by these variables:

  • s.trackingServer
  • s.trackingServerSecure

Part 2: Set tracking server variables

To determine which tracking server variables to use:

  1. Answer the questions in the decision matrix below. Use the variables that correspond to your answers.
  2. Replace the tracking server placeholders with your tracking server URLs.
  3. Remove unused tracking server and Experience Cloud server variables from the code.

Note: When used, match the Experience Cloud server URLs to their corresponding tracking server URLs like this:
  • Experience Cloud server URL = tracking server URL
  • Experience Cloud server secure URL = tracking server secure URL

If you're not sure how to find your tracking server see the FAQ and Correctly Populate the trackingServer and trackingServerSecure variables.

Step 5: Update Your AppMeasurement.js or s_code.js File

Add this function to your AppMeasurement.js or s_code.js file:

s.visitor = Visitor.getInstance("INSERT-MARKETING-CLOUD-ORGANIZATION ID-HERE");

Place the code in the same section that contains configurations such as linkInternalFilters, charSet, trackDownloads, etc.

(Optional but recommended) Create a Custom Prop

Set a custom prop in AppMeasurement.js or s_code.js to measure coverage. Add this custom prop to the doPlugins function of your AppMeasurement.js or s_code.js files:

// prop1 is used as an example only. Choose any available prop.
s.prop1 = (typeof(Visitor) != "undefined" ? "VisitorAPI Present" : "VisitorAPI Missing");

Step 6: Add Visitor API Code to the Page

Place the VisitorAPI.js file within the <head> tags on each page. When you the VisitorAPI.js file to your page:

  • Put it at the beginning of the <head> section to it appears before other solution tags.
  • It must execute before AppMeasurement and the code for other Experience Cloud solutions.

Move this code into production after testing and verification.

Step 7: (Optional) Configure a Grace Period

If any of these use cases apply to your situation, ask Customer Care to set up a temporary grace period. Grace periods can run for up to 180-days. You can renew a grace period if required.

Use Case Description

Partial Implementation

You need a grace period if you have some pages that use the ID service and some pages that do not, and they all report into the same Analytics report suite. This is common if you have a global report suite that reports across domains.

Discontinue the grace period after the ID service is deployed on all your web pages that report into the same report suite.

s_vi Cookie Requirements

You need a grace period if you require new visitors to have an s_vi cookie after migrating to the ID service. This is common if your implementation reads the s_vi cookie and stores it in a variable.

Discontinue the grace period after your implementation can capture the MID instead of reading the s_vi cookie.

See, Cookies and the Experience Cloud ID Service.

Clickstream Data Ingestion

You need a grace period if you send data to an internal system from a Clickstream data feed and that processes uses the visid_high and visid_low columns.

Discontinue the grace period after your data ingestion process can use the post_visid_high and post_visid_low columns.

See, Clickstream Data Column Reference.

Step 8: Test and Deploy ID Service Code

Procedure Description

Test and Verify

To test your ID service implementation, check for the:

See, Test and Verify the Experience Cloud ID Service.

Deployment

Deploy your code after it passes testing.

If you enabled a grace period in Step 7:

  • Ensure the Analytics ID (AID) and MID are in the image request.
  • Remember to disable the grace period once you meet the criteria for discontinuation.