-
Notifications
You must be signed in to change notification settings - Fork 732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experience Fragment enhancement to allow remote offer from Adobe Target #1424
base: main
Are you sure you want to change the base?
Changes from 1 commit
245d4f5
f1d7183
fc26f18
0cb3061
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,23 @@ | |
data-sly-set.selector="content.${request.requestPathInfo.selectorString}" | ||
data-sly-resource="${@path=fragment.localizedFragmentVariationPath, selectors=selector, wcmmode='disabled'}" | ||
id="${component.id}" | ||
class="cmp-experiencefragment cmp-experiencefragment--${fragment.name}"> | ||
class="cmp-experiencefragment cmp-experiencefragment--${fragment.name} ${properties.enableRemoteOffer ? ' mboxDefault' : ''}"> | ||
</div> | ||
<sly data-sly-call="${template.placeholder @ isEmpty=!fragment.configured, classAppend='cmp-dd-experiencefragment'}"></sly> | ||
<sly data-sly-call="${template.placeholder @ isEmpty=!fragment.configured, classAppend='cmp-dd-experiencefragment'}"></sly> | ||
|
||
<script data-sly-test="${properties.enableRemoteOffer && properties.id}" data-sly-set.mboxId="${properties.id}"> | ||
adobe.target.getOffer({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would make sure the global There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vladbailescu added the check to make sure adobe.target is available before it's called. |
||
mbox: "${mboxId @ context='scriptString'}", | ||
success: function (offer) { | ||
adobe.target.applyOffer({ | ||
mbox: "${mboxId @ context='scriptString'}", | ||
selector: "#${mboxId @ context='scriptString'}", | ||
offer: offer | ||
}); | ||
}, | ||
error: function (error) { | ||
var el = document.getElementById("${mboxId @ context='scriptString'}"); | ||
el.style.visibility = "visible"; | ||
} | ||
}); | ||
</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if we moved the script to a clientlib instead of inlining it. It could activate on page load and process all elements that have a certain data attribute (for example:
data-enable-remote-offer
).Also, shouldn't the
mboxId
leveragecomponent.id
instead oproperties.id
. It's a subtle difference but sometime they could be different.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vladbailescu I have moved the inline scripts into clientlib and added the data-attibutes.
Explicetely we are reading the mboxId from properties.id because that field is optional and if someone does not want to use the experience targeting offer, they will not configure the field in which case the backend sling model will generate a random id and which we do not want to use for target. So if any customer wants to use the target offer they will need to provide an id explicitly and the same will be used by both component.id and properties.id