Custom Integrations: Callback Functions

You are here:
< All Topics

Even though we have a lot of settings to make it very easy to change the look and feel and the content of the Result Page, there are times that you want to harness the power of the Product Recommendation Quiz but want to:

  • add custom code or logic
  • display custom product recommendations
  • forward to any particular page on your store

We made it very easy for developers to tap into the quiz response and get all the information they need: individual answers to questions, triggered tags and recommended products.

We provide this information via a JavaScript Callback Function that you can add on your own website; you just need to add a listener that will be triggered when the quiz is completed. Note that this callback function will also be triggered if they reach the results page via follow up emails you send your customers with a link to their results.

The callback function will receive a JSON with the quiz response. The JSON with the quiz response includes:

  • The complete set of questions that were asked
  • The responses your customer gave
  • The customer tags that were assigned to that customer
  • The products that were recommended
  • The layout and logic of the results page blocks 

 

How to set up the Callback Function

In order to get started with the implementation, your developer can add the following code in your store’s theme, just before the closing </head> tag:

<script>
  function prqQuizCallback(quizResponse){
    console.log(quizResponse);
  }
</script>

The above example is a simple console.log() function that renders a JSON with all the response data, but your developer can add all the code he or she wants here.

You can, for example, only add a prqAddOneToCartCallback(event); that will be triggered when a customer adds one product to the cart. To see the list of other callbackfunctions, check the “Additional Callback Functions” section below.

You can check out the console log output in the following demo store:
https://skincarequiz.myshopify.com/

Here’s how to find your browser’s developer console.

Additional Callback Functions

prqSlideCallback(event);
 // triggered when customer responds to a question (slide)
prqAddOneToCartCallback(event); // triggered when customer adds one product to cart prqAddedOneToCartCallback(event); // triggered when the product has already been added to the cart prqRemoveOneFromCartCallback(event); // triggered when customer removes one product from cart prqRemovedOneFromCartCallback(event); // triggered when the product has already been removed from the cart (only Shopify) prqAddAllToCartCallback(event); // triggered when customer adds all products to cart prqAddedAllToCartCallback(event); // triggered when all the products have already been added to the cart prqAppLoadedCallback(); // triggered when the Product Recommendation Quiz app has been loaded 

 

Table of Contents

Install the app and get started today

Add a Product Recommendation Quiz to your store and start offering a better shopping experience