All Collections
Quizzes
Developer Options
Guides
Redirecting to a Custom URL on Quiz Completion with Javascript
Redirecting to a Custom URL on Quiz Completion with Javascript

#developer #quiz #redirect

Mark Baek avatar
Written by Mark Baek
Updated over a week ago

The instructions in this article will go into what's needed to redirect to a custom URL at the end of a quiz, instead of using Octane AI's built-in result pages.

For more details on Octane AI's custom events, check out this article.

๐Ÿ’ก What you'll learn about


๐Ÿ’ก Prerequisites

  • Developer tools are available on the Octane Plus plan.

Using these features will require you to create custom code on your website that targets with your desired developer tool. This document serves as a starting point for those with the technical proficiency to build the next steps.


Developer tools you'll need

Redirecting to a custom URL at the end of a quiz will use:

  • Quiz completed custom event

This is a custom event fired at the end of a quiz that can be used to execute custom code when listened to.

The custom event will also include unique data on the specific quiz session including:

  • Selected quiz answers

  • Recommended products

    • Title

    • Description

    • Image

    • Tags

    • ID

    • Type

    • Product page link

  • Opt-in data

    • Email

    • Phone number

  • Built-in result page URL

Inside of Octane AI's quiz editor, you can find an example of what kind of output you might see when console logging the output of the octane.quiz.completed event.

Listening to the quiz completed event

Below is an example of how to use the method addEventListener() with an Octane AI custom event.

document.addEventListener('octane.quiz.completed', function (e) {
console.log('completed'); console.log(e.detail);
}, false);

Redirecting to a custom URL can be done by replacing the console.log() in the example with your own code for redirects.

Octane AI events are configured for bubbling up and information about each item can be accessed through the detail object property. In the example above, e.detail.answers would contain all quiz answers chosen in a session.

A more detailed explanation of addEventListener() including descriptions of all valid parameters can be found in this MDN web document.

Did this answer your question?