Event Callbacks
Event callbacks are hooks you can use to get feedback as users interact with the Emplifi Ratings & Reviews widgets on your product detail page. You can configure event callbacks in the turnToConfig
object as optional JavaScript functions that are called by the widgets when, for example, a user submits a question. Event callbacks are useful for a number of purposes, such as triggering an event record in your analytics package.
Event Handlers
These event callbacks are triggered when users interact with Emplifi Ratings & Reviews widgets and are configured in the turnToConfig.eventHandlers
object. See the installation section of the Event Callbacks article for example code.
onInstantAnswerClick - When a user clicks on a search result to view detail.
onQuestionSubmit - When a user successfully submits a question.
onAnswerSubmit - When a user successfully submits an answer.
onReviewSubmit - When a user successfully submits a review.
onCommentSubmit - When a user successfully submits a checkout comment.
Some event handlers have an evt
parameter, which gives you access to the id of the corresponding UGC object the event handler is associated with. For example, with the onQuestionSubmit
event handler, you can use evt.id
inside that event handler's code to access the id of the question that was just submitted.
onFinish and onUpdate Event Callbacks
These event callbacks are triggered when a widget has finished loading or reloading. See the installation section of the Event Callbacks article for example code.
Q&A
onFinish - When the Q&A widget has finished loading. Configured in the
turnToConfig.qa
object.
Review List
onFinish - When the Review List widget has finished loading. Configured in the
turnToConfig.reviewsList
object.onUpdate - When the Review List widget has finished reloading after a user sorts, searches, applies a filter or otherwise paginates. Configured in the
turnToConfig.reviewsList
object.
Visual Content
onFinish - When the Visual Content Gallery Row Widget has finished loading. Configured in the
turnToConfig.gallery
object.onFinish - When the Visual Content Pinboard has finished loading. Configured in the
turnToConfig.vcPinboard
object.
Checkout Comments Display
onFinish - When the Comments Display Widget has finished loading. Configured in the
turnToConfig.chatter
object.
Checkout Comments Top Comment
onFinish - When the Checkout Comments Top Comment Widget has finished loading. Configured in the
turnToConfig.topComments
object.
Checkout Comments Pinboard Teaser
onFinish - When the Checkout Comments Pinboard Teaser has finished loading. Configured in the
turnToConfig.commentsPinboardTeaser
object.
Teaser Link Event Callbacks
These event callbacks are triggered when a user clicks a link in the Teaser Widget. The most common use case is to change the behavior of the teaser's links, such as when content is hidden behind a tab and you need to display that tab before moving the user to the content. See Installation for example code.
showComments - Code to open and go to the comments tab when the user clicks the comment link in the Teaser Widget.
showQa - Code to open and go to the Q&A tab when the user clicks the Q&A link in the Teaser Widget.
showReviews - Code to open and go to the reviews tab when the user clicks the reviews link in the Teaser Widget.
Subdimension Teaser Link Event Callbacks
These event callbacks are triggered when a user clicks a link in the Subdimension Teaser widget. The most common use case is to change the behavior of the subdimension teaser's links, such as when content is hidden behind a tab and you need to display that tab before moving the user to the content. See the installation section of the Event Callbacks article for example code.
showReviews - Code to open and go to the reviews tab when the user clicks the reviews link in the Subdimension Teaser widget.
Installation
The snippet shown below controls all Emplifi Ratings & Reviews widgets installed on your product detail page, such as Ratings & Reviews. Place this snippet on your product detail page only one time for all widgets. If one or more widgets requires a specific configuration, such as the onFinish
function, add that config into your already existing snippet, as shown in this example on pastebin.
<script type="text/javascript">
var turnToConfig = {
locale: "en_US",
pageId: "pdp-page",
eventHandlers: {
//onInstantAnswerClick: function(){},
//onQuestionSubmit: function(evt){},
//onAnswerSubmit: function(evt){},
//onReviewSubmit: function(evt){},
//onCommentSubmit: function(evt){}
},
qa: {
//onFinish: function(){}
},
reviewsList: {
//onFinish: function(){},
//onUpdate: function(){}
},
gallery: {
//onFinish: function(){}
},
chatter: {
//onFinish: function(){}
},
topComments: {
//onFinish: function(){}
},
commentsPinboardTeaser: {
//onFinish: function(){}
},
vcPinboard: {
//onFinish: function(){}
},
subdimensionTeaser: {
showReviews: function() {
// Code to open and go to reviews summary/list tab
}
},
teaser: {
showComments: function() {
// Code to open and go to comments tab
},
showQa: function() {
// Code to open and go to Q&A list tab
},
showReviews: function() {
// Code to open and go to reviews summary/list tab
}
}
};
</script>