Information about at.js custom events
, which lets you know when an mbox request or offer fails or succeeds.
Historically, mbox.js (now deprecated) didn’t let other JavaScript code that runs on the page know what happens behind the scenes. With the advancement of at.js, we had a unique opportunity to fix this issue.
According to our customers there are several scenarios that they would like to be notified of, including:
Pre-defined events have a structure that allows you to extract the required data, based on event type.
To make sure that events can be used in different scenarios, the custom events have a payload object that is assigned to the detail property of the event object (that is passed to the handler). Also to avoid passing strings as event names, the events are exposed as constants using adobe.target.event
namespace.
Key | Type | Description |
---|---|---|
type | String | There are several scenarios in which you would like to be notified to help in tracing, debugging, and customizing interaction with at.js. Each custom event listed below has two formats: a “constant” and a “string value.”
Constant: String value: Description: An mbox request failed due to timeout, wrong status code, JSON parse error, etc. Request Succeeded Constant: String Value: Description: An mbox request was successful. Content Rendering Failed Constant: String Value: Description: Offer rendering failed due to wrapping mbox element missing, selector can not be found, etc. Content Rendering Succeeded Constant: String Value: Description: Offer rendering was successful. DOM changes have been applied. Library Loaded Constant: String Value: Description: This event is ideal to track when at.js has been fully loaded. You can use this event to customize global mbox execution. You can also use this event to disable the global mbox and then listen for this event to fire the global mbox later. Request Start Constant: String Value: Description: This event is fired before an HTTP request is executed. You can use this event for performance measurements using the Resource Timing API. Content Rendering Start Constant: String Value: Description: This event is fired before selector polling is started and content is rendered to the page. You can use this event to track the content rendering progress. Content Rendering No Offers Constant: String Value: Description: This event is fired when there are no offers returned. Content Rendering Redirect Constant: String Value: Description: This event is fired when an offer is a redirect and Target will redirect to a different URL. |
mbox | String | mbox name |
message | String | Contains human-readable description, such as what happened, the error message, etc. |
tracking | Object | Contains the sessionId and deviceId . In some cases, deviceId could be missing because Target couldn’t retrieve it from edge server. |
type | String | On-device decisioning artifact succeeded Constant:
String value: Description: Called when the on-device decisioning artifact is successfully downloaded. On-device decisioning artifact failed Constant: String Value: Description: Called when the on-device decisioning artifact failed to download. |
document.addEventListener(adobe.target.event.REQUEST_SUCCEEDED, function(event) {
console.log('Event', event);
});
Watch the following video to learn how to use Response Tokens and at.js Custom Events to share profile information from Target to third-party systems.