Javascript API
Demo System Profile Viewer provides a JavaScript API, which lets you fetch profile information, experience events and offers in your own JavaScript code. This is useful for scenarios like:
- Pre-populating forms with profile information
- Custom visualization of experience events
- Getting offers for web personalization
You can interact with Profile Viewer JavaScript API through a global DSN object and its functions. Under the hood, it takes care of authentication, passing ECID etc.
Initialization
DSN JavaScript API takes a moment to initialize so it's best to start using it after dsnApiReady event:
DSN.getProfile()
Parameters: none
Returns: promise which resolves with raw response from AEP API containing unified profile object.
DSN.getExperienceEvents()
Parameters: none
Returns: promise which resolves with raw response from AEP API containing a list of experience events for current profile.
DSN.getOffer(decisionScope, rawResponse)
Parameters: decisionScope - object containing activityId and placementId, copied from Offers UI

rawResponse - if true, returns a raw response from Offer Decisioning API, otherwise only the offer content will be returned.
Returns: promise which resolves with offer content or raw response (depending on rawResponse parameter) from Offer Decisioning API for given decision scope and current ECID.
// by default, only offer content is returned
DSN.getOffer({
"xdm:activityId":"xcore:offer-activity:12d395521494f789",
"xdm:placementId":"xcore:offer-placement:12c179867ece8ad8"
}).then(function(offerContent) {
console.log(offerContent)
})
// to get the whole response, pass true as rawResponse parameter
DSN.getOffer({
"xdm:activityId":"xcore:offer-activity:12d395521494f789",
"xdm:placementId":"xcore:offer-placement:12c179867ece8ad8"
}, true).then(function(rawResponse) {
console.log(rawResponse)
});