This implementation path involves a methodical migration approach to move from an AppMeasurement implementation to a Web SDK JavaScript library implementation. Other implementation paths are covered on separate pages:
data
object instead of the xdm
object to send data to Adobe.alloy.js
). Manage the implementation yourself instead of using the tags UI. It requires the Adobe Analytics ExperienceEvent field group, which includes typical Analytics variables to be included in your XDM schema.Using this migration approach has both advantages and disadvantages. Carefully weigh each option to decide which approach is best for your organization.
Advantages | Disadvantages |
---|---|
|
|
Adobe recommends following this implementation path in the following scenarios:
The following steps contain concrete goals to work towards. Click each step for detailed instructions on how to accomplish it.
Create a datastream in Adobe Experience Platform Data Collection. When you send data to this datastream, it forwards data to Adobe Analytics. In the future, this same datastream forwards data to Customer Journey Analytics.
Your datastream is now ready to receive and pass along data to Adobe Analytics. Note the datastream ID, as this ID is required when configuring the Web SDK in code.
Reference the latest version of alloy.js
so its method calls can be used. See Install the Web SDK using the JavaScript library for details and code blocks to use.
Set up your implementation to point to the datastream created in the previous step by using the Web SDK configure
command. The configure
command must be set on every page, so you can include it alongside the library installation code.
Use the datastreamId
and orgId
properties within the Web SDK configure
command:
datastreamId
to the datastream ID retrieved from the previous step.orgId
to your organization’s IMS org.alloy("configure", {
datastreamId: "ebebf826-a01f-4458-8cec-ef61de241c93",
orgId: "ADB3LETTERSANDNUMBERS@AdobeOrg"
});
You can optionally set other properties in the configure
command depending on your organization’s implementation requirements.
Change your Analytics implementation so that it does not rely on AppMeasurement.js
or the s
object. Instead, set variables into a correctly formatted JavaScript object, which is converted to a JSON object when sent to Adobe. Having a Data layer on your site helps tremendously when setting values, as you can continue referencing those same values.
To send data to Adobe Analytics, the Web SDK payload must use data.__adobe.analytics
with all analytics variables set within this object. Variables within this object share identical names and formats as their AppMeasurement variable counterparts. For example, if you set the products
variable, do not split it into individual objects like you would with XDM. Instead, include it as a string exactly is if you set the s.products
variable:
{
"data": {
"__adobe": {
"analytics": {
"products": "Shoes,Men's sneakers,1,49.99"
}
}
}
}
Ultimately, this payload contains all desired values, and all references to the s
object in your implementation are removed. You can use any of the resources that JavaScript provides to set this payload object, including dot notation to set individual values.
// Define the payload and set objects within it
var dataObj = {data: {__adobe: {analytics: {}}}};
dataObj.data.__adobe.analytics.pageName = window.document.title;
dataObj.data.__adobe.analytics.eVar1 = "Example value";
// Alternatively, set values in an object and use a spread operator to achieve identical results
var a = new Object;
a.pageName = window.document.title;
a.eVar1 = "Example value";
var dataObj = {data:{__adobe:{analytics:{...a}}}};
Update all instances where you call s.t()
and s.tl()
, replacing them with the sendEvent
command. There are three scenarios to consider:
Page view tracking: Replace the page view tracking call with the Web SDK sendEvent
command:
// If your current implementation has this line of code:
s.t();
// Replace it with this line of code. The dataObj object contains the variables to send.
alloy("sendEvent", dataObj);
Automatic link tracking: The clickCollectionEnabled
configuration property is enabled by default. It automatically sets the correct link tracking variables to send data to Adobe Analytics. If you want to disable automatic link tracking, set this property to false
within the configure
command.
Manual link tracking: The Web SDK does not have separate commands between pageview and non-pageview calls. Provide that distinction within the payload object.
// If your current implementation has this line of code:
s.tl(true,"o","Example custom link");
// Replace it with these lines of code. Add the required fields to the dataObj object.
dataObj.data.__adobe.analytics.linkName = "Example custom link";
dataObj.data.__adobe.analytics.linkType = "o";
dataObj.data.__adobe.analytics.linkURL = "https://example.com";
alloy("sendEvent", dataObj);
Once you have removed all references to AppMeasurement and the s
object, publish your changes to your development environment to validate that the new implementation works. Once you have validated that everything works correctly, you can publish your updates to production.
If migrated correctly, AppMeasurement.js
is no longer required on your site, and all references to this script can be removed.
At this point, your Analytics implementation is fully on the Web SDK and is adequately prepared to move to Customer Journey Analytics in the future.