How Can We Help?

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 quizCallback(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 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

addOneToCartCallback(event); // triggered when customer adds one product to cart
removeOneFromCartCallback(event); // triggered when customer removes one product from cart
addAllToCartCallback(event); // triggered when customer adds all products to cart


Table of Contents

Get a quote in one minute for free

Start getting more leads and more sales for your Shopify app today