Integrate event callbacks

Integrate event callbacks

JavaScript event callbacks let your website respond to events that occur in the Bazaarvoice application, such as a consumer opening a review submission form. The Bazaarvoice application exposes a set of JavaScript events you can use to respond to specific events. When a consumer triggers the event, the Bazaarvoice code executes the callback function associated with the event, passing an object containing data about the event.

You can use JavaScript event callbacks to record and respond to customer interactions with the Bazaarvoice application. For example, you can:

  • Record when a consumer lands on a page rendering the Bazaarvoice application.
  • Record information about a consumer, such as name, phone number, and email address.
  • Measure the impact of certain events on key conversion metrics, such as the number of times consumers open but don’t submit the review submission form.
  • Display content in response to a consumer’s interaction with the Bazaarvoice application, such as displaying a coupon after the consumer completes a review.

Complete the following steps to integrate JavaScript event callbacks:

  1. Select an event you want to watch.

    When you specify a callback for an event, the callback function executes when the event occurs. You can specify a callback for the following events:

    • bvRender—triggered when the application initially renders on the site. In the V2 implementation, a specific event will be triggered twice, first for Ratings & Reviews and then again for Question & Answers.
    • submissionLoad—triggered when a consumer opens a submission form for such activities as writing a review, asking a question or answering a question.
    • submissionClose—triggered when a consumer closes a submission form.
    • submissionSubmitted—triggered when a consumer submits a submission form.

    When you specify a callback function for one of these events, the function can receive an object as its sole argument. This object contains information about the event. You can select from the following object properties:

    Element Value Applicable events
    id Product ID All events
    TotalAnswerCount Total number of answers for the product All events from V2 Questions & Answers
    TotalQuestionCount Total number of questions for the product All events from V2 Questions & Answers
    TotalReviewCount Total number of reviews for the product All events from V2 Ratings & Reviews
    TotalContentCount Total number of content types for the product, if applicable All events
    BVProduct Name of the display application from which the event is triggered. Possible values are swat_reviews, swat_questions, and inpage_submission All events
    ContentType Type of content associated with the submission. Possible values include Reviews, Questions, and Answers. submissionLoad, submissionClose, and submissionSubmitted.
    SubmittedStep Indicates the step in the form that has been submitted. Possible values include mandatory, photoVideo, personalInformation, productRating, and brandDetails. submissionSubmitted event for Review submission in V2 Ratings & Reviews.
  2. Add a callback function to BV.configure global configuration.

    Locate the BV.configure call in your code, and add the event callback with the JavaScript code you want to execute when the event occurs. The following code associates a callback function with the bvRender event.

    HTML
    <script>
            // Make sure that BV.configure is defined before running this script
             BV.configure('global', {
             events : {
                bvRender : function (data) {
                // JavaScript code that executes when the Bazaarvoice application renders.
    }
    }
    });</script>
Provide feedback button