|
| 1 | +# Product quiz |
| 2 | + |
| 3 | +## Core purpose |
| 4 | + |
| 5 | +The application enables store owners to build custom quizzes through the Shopify admin interface. Each quiz consists of multiple questions with various answer options, and merchants can associate specific product recommendations with different answer combinations. When customers take a quiz, their responses are analyzed to generate personalized product suggestions, creating a more engaging and guided shopping experience. |
| 6 | + |
| 7 | +The app includes both an admin interface for merchants to manage their quizzes (create, edit, and configure product mappings) and a customer-facing quiz interface that can be embedded directly into Shopify storefronts via a theme extension. Customer quiz results and product suggestions are tracked, allowing merchants to analyze engagement and optimize their product recommendations over time. |
| 8 | + |
| 9 | +## Setup |
| 10 | + |
| 11 | +The following is a guide to get you started with the product quiz. If you get lost, try following the [full tutorial](https://docs.gadget.dev/guides/tutorials/product-recommendation-quiz-app). |
| 12 | + |
| 13 | +1. [Connect to Shopify](https://docs.gadget.dev/guides/tutorials/connecting-to-shopify#connecting-to-shopify) using our built-in Shopify plugin. |
| 14 | + |
| 15 | +2. Make sure that you have the [Shopify CLI](https://shopify.dev/docs/api/shopify-cli#installation) installed locally. |
| 16 | + |
| 17 | +3. Find the application slug and the environment slug. You'll need them for step 4. |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +4. Create a shopify app proxy that has proxy URL matching `https://<application-slug>--<env-slug>.gadget.app/proxy`. Note the subpath used in the theme app extension's JS file. For more information on Shopify app proxies, read the [Shopify docs](https://shopify.dev/docs/apps/build/online-store/display-dynamic-data) |
| 22 | + |
| 23 | +## Setting up liquid files (Online store 1.0) |
| 24 | + |
| 25 | +For themes using Online Store 1.0, instructions are included in the **Install** tab of the admin app. You need to manually copy-paste code files included in the app into the theme. |
| 26 | + |
| 27 | +## Setting up App Theme Extension (Online store 2.0) |
| 28 | + |
| 29 | +In order to set up a theme app extension for stores using a new Online Store 2.0 theme: |
| 30 | + |
| 31 | +- Update `extensions/quiz/blocks/quiz-page.liquid` by replacing the src on line 7 with your script tag |
| 32 | +- Run `yarn dev` in the project root to start the development environment (Shopify CLI) |
| 33 | +- Follow Shopify's prompts to connect to your existing Partners app and store |
| 34 | + |
| 35 | +## Key features |
| 36 | + |
| 37 | +- Models |
| 38 | + |
| 39 | + - Quiz: Framework for creating and storing quizzes. |
| 40 | + - Fields |
| 41 | + - `slug`: The slug that will be used to determine which quiz to show the customer |
| 42 | + - `title`: The title of the product quiz |
| 43 | + - `results`: A hasMany relationship to the results of this quiz |
| 44 | + - `questions`: The questions on the quiz |
| 45 | + - Question: Individual questions included in a quiz. |
| 46 | + - Fields |
| 47 | + - `text`: The body of the question |
| 48 | + - `quiz`: The quiz that the question belongs to |
| 49 | + - `answers`: The answers associated to the question |
| 50 | + - Answer: Possible answers for a quiz question. |
| 51 | + - Fields |
| 52 | + - `text`: The body of the answer |
| 53 | + - `question`: The question that the answer belongs to |
| 54 | + - `recommendedProduct`: The product that is recommended for this answer |
| 55 | + - RecommendedProduct: A Shopify product recommended to shoppers based on their quiz answers. |
| 56 | + - Fields |
| 57 | + - `productSuggestion`: The suggested product |
| 58 | + - `answer`: The answer that the recommendation belongs to |
| 59 | + - QuizResult: Captures the shopper's email and the products recommended to them based on their quiz answers. |
| 60 | + - Fields |
| 61 | + - `email`: The email of the customer that filled out the form |
| 62 | + - `shopperSuggestion`: The product that was recommended to the customer |
| 63 | + - `quiz`: The quiz that the result record belongs to |
| 64 | + - ShopperSuggestion: Handles the has-many-through relationship between quizResult and shopifyProduct. |
| 65 | + - Fields |
| 66 | + - `product`: The product that the suggestion belongs to |
| 67 | + - `quizResult`: The quiz result record that the product belongs to |
| 68 | + - ShopifyTheme: Tracks whether a theme is using Shopify's Online Store 2.0. |
| 69 | + - Fields |
| 70 | + - `usingOnlineStore2`: Boolean field signifying if the store is using a Shopify 2.0 theme |
| 71 | + |
| 72 | +- Frontend |
| 73 | + |
| 74 | + - `App.jsx`: Handles routing for the frontend pages. |
| 75 | + - `HomePage.jsx`: Main page for the Shopify admin app. |
| 76 | + - `CreateQuizPage.jsx`: Contains the form for creating new quizzes. |
| 77 | + - `EditQuizPage.jsx`: Contains the form for editing existing quizzes. |
| 78 | + - `QuizForm.jsx`: Entry point for the form used to create and edit quizzes. |
| 79 | + - `InstallTab.jsx`: Provides installation instructions for adding the quiz to the storefront. |
| 80 | + - `Store1Instructions.jsx`: Manual instructions for themes built on Online Store 1.0. |
| 81 | + |
| 82 | +- Actions |
| 83 | + |
| 84 | + - `quiz/create`: Generates an ID/slug when a quiz is created (e.g., "My Cool Quiz" becomes "my-cool-quiz"). |
| 85 | + - `quiz/delete`: Cascading delete that removes a quiz along with its questions, answers, and recommended products. |
| 86 | + - `shopifyAsset/create`: Detects whether the shop is using Shopify Storefront 1.0 or 2.0. |
| 87 | + - `shopifyAsset/update`: Updates to detect the shop’s storefront version. |
| 88 | + |
| 89 | +- Access Controls |
| 90 | + |
| 91 | + - `unauthenticated`: Quizzes can be viewed by anyone who visits the shop, regardless of whether they are logged in. |
| 92 | + - `shopify-app-users`: Merchants can only read themes from their store. |
0 commit comments