Skip to main content
All CollectionsDeveloper Docs
Programmatically Submit Opt-In Information in Your Quizzes
Programmatically Submit Opt-In Information in Your Quizzes

Remove redundancy in the opt-in process.

Ariel Santos avatar
Written by Ariel Santos
Updated over a week ago

To improve the user experience during quiz-based profile building, you can now programmatically submit email and phone opt-ins directly to your quiz.

๐Ÿ’ก What you'll learn


๐Ÿ’ก Prerequisites

How this works and what are the benefits and use cases

  • Skip Redundant Opt-In: If you already have an opt-in database, this feature allows you to avoid asking the customer for consent again during the quiz. The system will automatically mark the customer as "consented" for email and phone opt-ins, skipping those questions.

  • Seamless Profile Building: For logged-in customers, you can pass their information into the quiz, creating a complete profile without additional input from the user.

  • Supports Internal and Utility Quizzes: This feature is ideal for internal quizzes or utility quizzes, where the goal is to collect user data efficiently without additional friction.

This feature allows for a smoother and more integrated quiz experience, reducing unnecessary steps for customers who are taking the quiz while ensuring that all opt-in requirements are met.

How to set up the programmatic opt-in process

  1. Listening for the questionLoaded event:

    Before the quiz is initiated, your code should listen for the questionLoaded JavaScript event to identify when the first question of the quiz has been loaded.

  2. Firing the opt-in submission event:

    Then, your code should fire the octane.quiz.action.submit_optin event, which will contain the user's email and phone opt-in information. This will load their opt-in information in the quiz. You can send both the email and phone number at once, or just one of them, but they need to be valid. This event can only be fired once in the quiz.

    Below is an example of how this event can be fired:

    document.dispatchEvent(new CustomEvent('octane.quiz.action.submit_optin',
    {
    detail: {
    email: '[email protected]',
    phone_number: '+1234567890'
    }
    }
    ));

  3. Backend Handling:

    Upon receiving the opt-in details (email and phone number), the backend will automatically "answer" the opt-in questions with the provided values, so the opt-in questions will be skipped for the customer.

    This ensures that:

    • The quiz behaves as though the customer manually answered the opt-in question.

    • All related events (e.g., creating user identities) are triggered correctly.

    • The opt-in status is recorded in the database.

Did this answer your question?