Track Target conversion events using Platform Web SDK
Conversion events for Target can be tracked with the Platform Web SDK similar to at.js. Conversion events typically fall into the following categories:
- Automatically tracked events that do not require any configuration
- Purchase conversion events that should be adjusted for a best practice Platform Web SDK implementation
- Non-purchase conversion events that require code updates
Goal tracking comparison
The following table compares how at.js and Platform Web SDK track conversion events
context.address.url in the at.js request payload.xdm.web.webPageDetails.URL in the sendEvent payloadtrackEvent() or sendNotifications() with a type value of display.sendEvent call with the eventType of decisioning.propositionDisplay.notifications object in the in request payload and a type value of click.sendEvent call with the eventType of decisioning.propositionInteract.Automatically tracked events
The following conversion goals do not require any specific adjustments to your implementation:
- Conversion > Viewed a Page
- Conversion > Clicked an Element
- Engagement > Page Views
- Engagement > Time on Site
xdm.web.webPageDetails.URL value contains the full page URL with the proper character case.Custom-tracked events
Target implementations commonly use custom conversion events to track clicks for form-based activities, to signify a conversion in a flow, or to pass parameters without requesting new content.
The table below outlines the at.js approach and the Platform Web SDK equivalent for a few common conversion-tracking use cases.
trackEvent() or sendNotifications() with a type value of click for a specific mbox locationsendEvent command with an event type of decisioning.propositionInteracttrackEvent() or sendNotifications() with a type value of display for a specific mbox locationsendEvent command with an event type of decisioning.propositionDisplaydecisioning.propositionDisplay is most commonly used for incrementing impressions for specific scopes, it should also be used as a direct replacement for at.js trackEvent() usually. The trackEvent() function defaults to a type of display if not specified. Check your implementation to ensure you use the correct event type for any custom conversions you may have defined.Refer to the dedicated at.js documentation for more information on how to use and for tracking Target events.
at.js example using trackEvent() to track a click on an mbox location:
adobe.target.trackEvent({
"type": "click",
"mbox": "homepage_hero"
});
With a Platform Web SDK implementation, you can track events and user actions by calling the sendEvent command, populating the _experience.decisioning.propositions XDM field group, and setting the eventType to one of two values:
decisioning.propositionDisplay: Signals the rendering of the Target activity.decisioning.propositionInteract: Signals a user interaction with the activity, like a mouse click.
The _experience.decisioning.propositions XDM field group is an array of objects. The properties of each object are derived from the result.propositions that gets returned in the sendEvent command: { id, scope, scopeDetails }
alloy("sendEvent", {
xdm: { ...},
decisionScopes: ["hero-banner"]
}).then(function (result) {
var propositions = result.propositions;
if (propositions) {
// Find the discount proposition, if it exists.
for (var i = 0; i < propositions.length; i++) {
var proposition = propositions[i];
for (var j = 0; j < proposition.items; j++) {
var item = proposition.items[j];
if (item.schema === "https://ns.adobe.com/personalization/measurement") {
// add metric to the DOM element
const button = document.getElementById("form-based-click-metric");
button.addEventListener("click", event => {
const executedPropositions = [
{
id: proposition.id,
scope: proposition.scope,
scopeDetails: proposition.scopeDetails
}
];
// send the click track event
alloy("sendEvent", {
"xdm": {
"eventType": "decisioning.propositionInteract",
"_experience": {
"decisioning": {
"propositions": executedPropositions
}
}
}
});
});
}
}
}
}
});
Next, learn how to enable cross-domain ID sharing for consistent visitor profiles.