Installing Quizzes on Headless Instances
Overview
Okendo Quizzes can not only recommend products to your customers but give you insights into respondant order attribution, attributed revenue and add to cart clicks. Add to cart events can be registered from either the quiz recommendation page within the Okendo quiz or after completion on the product display page if the customer has completed a quiz.
Quick Start Guide
A bare minimum headless implementation of Okendo Quizzes will require the following:
Inclusion of Okendo Quizzes
The Okendo Quizzes script must be loaded on any page that:
Will show a quiz, or
Will provide the ability to add a product to the cart, or
Can potentially place/confirms success of an order.
Implementation of required Integration Points
The following events must be handled and/or dispatched as part of any headless/custom cart implementation:
Enable Add to Cart functionality for products recommended by the quiz:
oke_quizCapture_addToCart
oke_quizCapture_addToCartSuccess
oke_quizCapture_addToCartFailure
Enable attribution of quiz response data and reporting in the Okendo backend:
oke_connect_cart_itemVariantAdded
oke_connect_checkout_orderSubmitted
See the relevant sections under Integration Points and Implementation Examples for further details and code samples.
Add a Quiz to a page
A quiz can be included on a page in one of two ways. We currently recommend that only one quiz is shown per page.
Embedded Quizzes
Once a quiz has been configured in the Okendo backend it can be embedded into any page with the Install Snippet. To retrieve the snippet for any given quiz:
Navigate to the Quizzes section of the Okendo backend
Locate the quiz in the Quiz List
Click the “…” button to find the option to “Install” the quiz
Reveal the installation instructions for an Embedded Section (click ”Show Install Instructions”)
Copy the “Embed Quiz Snippet In Theme“ snippet and paste it into the desired location on the page
It should resemble the below:
Pop-up Quizzes
Merchants that prefer to show the Quiz in a pop up can use the showQuiz
function available on okeConnectApi
. See the relevant sections under Integration Points and Implementation Examples.
Integration Points
Add to Cart Functionality
Required for headless implementations
Merchants that have a custom cart implementation will need to notify Okendo Quizzes of whether a particular “Add to Cart” operation was successful or not. The dispatch of either a “success” or “failure” event will allow Okendo Quizzes to provide accurate visual feedback when a customer clicks “Add to Cart” on a recommended product.
oke_quizCapture_addToCart
: Dispatched by Okendo. This event is used to notify you that a customer intends to “Add to Cart” one or more recommended products.oke_quizCapture_addToCartSuccess
: Dispatched by you. This event is used to visually indicate to customers that an “Add to Cart” operation succeeded.oke_quizCapture_addToCartFailure
: Dispatched by you. This event is used to visually indicate to customers that an “Add to Cart” operation failed.
Attribution & Buyer Behavior
Required for headless implementations
oke_connect_cart_itemVariantAdded
: Dispatched by you. This event is used for the store to notify Okendo Quizzes when an add to cart event has occurred on the storefront. This event allows merchants to attribute data to the quiz response and feeds into reporting on quiz performance and buyer behavior.oke_connect_checkout_orderSubmitted
: Dispatched by you. This event is used for the store to notify Okendo Quizzes when an order is placed on the storefront. This event enables merchants to attribute the order with the quiz response, gathering valuable insights and feedback from customers to improve the overall effectiveness and relevance of the quizzes.okendo_attribution_session_id
: This attribute is added to cart attributes when the cart is created with the storefront API for the store to notify Okendo Quizzes when an order is processed on the storefront. This attribute enables merchants to attribute the order with the quiz response, gathering valuable insights and feedback from customers to improve the overall effectiveness and relevance of the quizzes.okendo_quiz_response_id
: This attribute is added to cart attributes when the cart is created with the storefront API for the store to notify Okendo Quizzes when an order is processed on the storefront. This attribute enables merchants to attribute the order with the quiz response, gathering valuable insights and feedback from customers to improve the overall effectiveness and relevance of the quizzes.
Here is an example implementation for the okendo_attribution_session_id
and okendo_quiz_response_id
attributes when updating cart attributes:
Pop-up Quizzes
Optional
In place of embedding a quiz on a page with an app block or embed snippet, Merchants have the alternative option to display a quiz in a pop up at a time that suits for added flexibility.
showQuiz
: Called by you. This function is used to display the quiz to the customer. By triggering this function at the appropriate time, merchants can engage customers and encourage them to interact with the quiz, resulting in a more interactive and personalized shopping experience.
Custom HTML
Optional
recommendedProductMounted
: Provided by you, called by Okendo. This function is called when an individual product recommendation is mounted in the application. It can be used for inserting custom HTML or other custom product display functionality, allowing merchants to further customize the presentation of recommended products.recommendedProductsMounted
: Provided by you, called by Okendo. This function is called when all product recommendations are mounted in the application. It can be used for inserting custom HTML or other custom product display functionality for the entire recommendation page, providing merchants with the flexibility to tailor the appearance of the entire recommendation section.
Product Properties
Optional
generateCartLineItemProperties
: Provided by you, called by Okendo. This event is triggered when a product is added to the cart from the recommendation page. It can be used to insert custom data into the cart line items, allowing merchants to enhance the cart experience with personalized information.
By leveraging the Quiz Frontend API, merchants can seamlessly integrate Okendo Quizzes and provide an engaging and personalized experience for their customers.
Implementation Examples
oke_quizCapture_addToCart
Event Usage
oke_quizCapture_addToCart
Event UsageThe oke_quizCapture_addToCart
event is used by Okendo Quizzes to notify the store that a customer intends to “Add to Cart” one or more recommended products.
An example implementation on how a custom cart might react to the oke_quizCapture_addToCart
event:
oke_quizCapture_addToCartSuccess
Event Usage
oke_quizCapture_addToCartSuccess
Event UsageThe oke_quizCapture_addToCartSuccess
event is used for the store to notify Okendo Quizzes that an add to cart event was successfully processed (by your custom cart implementation).
Here is an example implementation for the oke_quizCapture_addToCartSuccess
event:
oke_quizCapture_addToCartFailure
Event Usage
oke_quizCapture_addToCartFailure
Event UsageThe oke_quizCapture_addToCartFailure
event is used for the store to notify Okendo Quizzes that your/a custom cart implementation failed to process an add to cart event.
Here is an example implementation for the oke_quizCapture_addToCartFailure
event:
oke_connect_cart_itemVariantAdded
Event Usage
oke_connect_cart_itemVariantAdded
Event UsageThe oke_connect_cart_itemVariantAdded
event is used for the store to notify Okendo Quizzes when an add to cart event has occurred on the storefront. This is particularly useful for enabling attribution on headless implementations. This event allows merchants to attribute data to the quiz response and feeds into reporting on quiz performance and buyer behavior.
Here is an example implementation for the oke_connect_cart_itemVariantAdded
event:
In the above implementation, the oke_connect_cart_itemVariantAdded
event is dispatched using the document.dispatchEvent
method. The event includes the following details:
productId
(string): The unique identifier of the product added to the cart.variantId
(string): The unique identifier of the selected variant of the product.quantity
(number): The quantity of the product added to the cart.
By dispatching the oke_connect_cart_itemVariantAdded
event with the relevant information, merchants can track add to cart events and associate them with the quiz response, providing valuable insights into the effectiveness of quizzes in driving buyer behavior.
Remember to replace 'your-product-id'
and 'your-variant-id'
with the actual product and variant IDs from your storefront.
By leveraging the oke_connect_cart_itemVariantAdded
event provided by the Quiz Frontend API, merchants can seamlessly integrate Okendo Quizzes and gather valuable data on quiz performance and buyer behavior.
oke_connect_checkout_orderSubmitted
Event Usage
oke_connect_checkout_orderSubmitted
Event UsageThe oke_connect_checkout_orderSubmitted
event is used for the store to notify Okendo Quizzes when an order is placed on the storefront. This is particularly useful for enabling attribution on headless implementations. This event enables merchants to attribute the order with the quiz response, gathering valuable insights and feedback from customers to improve the overall effectiveness and relevance of the quizzes.
Here is an example implementation for the oke_connect_checkout_orderSubmitted
event:
In the above implementation, the oke_connect_checkout_orderSubmitted
event is dispatched using the document.dispatchEvent
method. The event includes the following details:
cartToken
(string)(optional): The token representing the user's cart.checkoutToken
(string)(optional): The token representing the user's checkout session.orderId
(string)(optional): The unique identifier of the order placed on the storefront.products
(array of objects): An array of products included in the order, where each object contains the following details:productId
(string): The unique identifier of the product.variantId
(string): The unique identifier of the selected variant of the product.quantity
(number): The quantity of the product added to the cart.
By dispatching the oke_connect_checkout_orderSubmitted
event with the relevant information, merchants can link the order with the quiz response, gaining insights into the impact of quizzes on customer purchasing behavior.
Remember to replace 'your-cart-token'
, 'your-checkout-token'
, 'your-order-id'
, 'your-product-id'
, and 'your-variant-id'
with the actual tokens, order ID, product ID, and variant ID from your storefront.
By leveraging the oke_connect_checkout_orderSubmitted
event provided by the Quiz Frontend API, merchants can seamlessly integrate Okendo Quizzes and gather valuable data on the impact of quizzes on customer orders.
showQuiz
Function Usage
showQuiz
Function UsageThe showQuiz
event can optionally be used to trigger display of Okendo Quizzes on your storefront in a modal. By triggering this event at the appropriate time, you can display the quiz to your customers and create a more interactive and personalized shopping experience. Here is an example implementation for the showQuiz
event:
In the above implementation, the showQuiz
event takes two parameters:
channelQuizId
(string): The unique identifier of the quiz channel. You can find this ID in the install dialogue of the quiz you want to display in the Okendo admin application.subscriberId
(string): Your Okendo subscriberId.
Once you have implemented the showQuiz
event, you can call it at the appropriate time in your storefront's code to display the quiz to your customers.
Remember to customize the appearance and behavior of the quiz to align with your branding and provide an engaging experience for your customers.
By leveraging the showQuiz
event provided by the Quiz Frontend API, you can seamlessly integrate Okendo Quizzes and enhance the overall shopping experience for your customers.
A sample custom liquid snippet for a button that shows the quiz in a popup
recommendedProductMounted
Function Example
recommendedProductMounted
Function ExampleThe recommendedProductMounted
event is triggered when an individual product recommendation is mounted in the application. It provides an opportunity for merchants to insert custom HTML or other custom product display functionality, allowing them to further customize the presentation of recommended products. Here is an example implementation for the recommendedProductMounted
event and using it to insert an additional product option selector:
In the above implementation, the recommendedProductMounted
event provides the following:
sectionContent
(html): The html content that will be rendered for the recommended product.For example:
product
(json): A JSON object representing the recommended product and associated properties.For example:
By implementing the recommendedProductMounted
event, merchants can customize the appearance and behavior of individual recommended products, providing a tailored and personalized shopping experience for their customers.
recommendedProductsMounted
Function Example
recommendedProductsMounted
Function ExampleThe recommendedProductsMounted
event is triggered when all product recommendations are mounted in the application. It provides an opportunity for merchants to insert custom HTML or other custom product display functionality for the entire recommendation page. This allows merchants to have full control over the presentation of the entire recommendation section. Here is an example implementation for the recommendedProductsMounted
event:
In the above implementation, the recommendedProductsMounted
event provides the following:
recommendationSection
(html): The html element representing the entire recommendation section.products
(json): A JSON object representing all recommended products to be displayed on the recommendation page.
By implementing the recommendedProductsMounted
event, merchants have the flexibility to insert custom HTML or other custom product display functionality for the entire recommendation page. This allows for a highly customizable and tailored shopping experience for their customers.
generateCartLineItemProperties
Function Example
generateCartLineItemProperties
Function ExampleThe generateCartLineItemProperties
event is triggered when a product is added to the cart from the recommendation page. It provides an opportunity for merchants to insert custom data into the cart line items, allowing them to enhance the cart experience with personalized information. Here is an example implementation for the generateCartLineItemProperties
event:
In the above implementation, the generateCartLineItemProperties
event provides the following:
addToCartButtonId
(string): id of the add to cart button element that was clicked.product
(json): A JSON object representing the product that was added to the cart from the recommendation page.
By implementing the generateCartLineItemProperties
event, merchants can enrich the cart experience by including custom properties for each line item. This allows for a more personalized and tailored shopping experience for their customers.
Last updated