# Reuse earlier answers in question text

Put an earlier answer into a later question. For example, if someone says they bought a notebook, ask “What made you choose the notebook?” Shopoll fills in the product they named.

## Name the earlier question

1. Open your first question and open **Question options → Personalize question text**.
2. In **Question handle**, enter a unique name such as `product`. Use letters, numbers and underscores. Start with a letter or underscore. If the question title is already a single suitable name, you can use it directly.
3. In a later question enter `What would you change about your {{product}}?` as the **Question text**. Choose **Preview current draft** and answer the first question. Go back and change the answer to try another follow-up.

In a later question, open **Question options → Personalize question text** to copy a variable from an earlier question. If several are available, choose the one you want under **Earlier question**. Paste the variable into the wording wherever the answer should appear.

A question can use answers to questions the person has already seen on their route through the survey. A multiple-choice answer displays as a comma-separated list.

## Choose a fallback

If an answer is missing, its place in the question text is left blank. To keep the question readable, try `What would you change about {{print product "your order"}}?`. To change the whole sentence use a conditional.

```handlebars
{{#if product}}How did the {{product}} fit?{{else}}How did your order fit?{{/if}}
```

Use `{{#each product}}{{this}}{{#unless @last}}, {{/unless}}{{/each}}` to format a list. An invalid expression remains visible in preview so you can correct it.

## Personalise a field in a form

Suppose a shopper chooses **travel mug** in a question with the handle `product`. Add a **Form panel** as the next question. Under **Form fields**, set a field label to `What would you change about your {{product}}?`. The shopper sees “What would you change about your travel mug?” If they go back and choose **bottle**, the field updates to “What would you change about your bottle?”

![A shopper who chose bottle sees that answer in the next form field and its placeholder.](/docs/media/form-answer-variable.png)

Field placeholders and matrix row labels can also use variables. Include the variable in each translation that needs the answer. A missing or skipped answer can use a fallback such as `{{print product "your purchase"}}`.

## Look up a value in a list

If your site supplies an array named `products`, use `{{lookup products 0}}` to show its first item. For an array of objects, `{{#with (lookup products 0)}}{{name}}{{/with}}` shows the first product’s name. For a score that can be zero, `{{#if score includeZero=true}}{{score}}{{else}}No score{{/if}}` displays a recorded zero.

## Pass a value from your website

Set `window.Shopoll.templateVariables` on the page containing your embed. Provide ordinary JSON values before the survey loads. For example, set a collection name on a product page.

```javascript
window.Shopoll = window.Shopoll || {};
window.Shopoll.templateVariables = { collection: "Winter layers" };
```

A question can now say `What were you looking for in {{collection}}?`. Page values take priority over earlier answers, which take priority over survey metadata such as `utm_source`. The embed passes these display values directly into the survey frame. A standalone survey link uses its own metadata and earlier answers.

## Ask about a Shopify purchase

On the Thank you and Order status pages, product and variant IDs can determine **which survey appears**. For example, a merchant can write “Why did you choose the cobalt cover?” and set the order audience to the cobalt variant ID. An order containing that variant qualifies even if it contains other items.

Shopoll does not automatically insert a purchased product name or colour into the question. For a survey shown to every order, ask “What made you decide to place your order today?” To refer to a specific item in a follow-up, ask the shopper which item they mean and reuse their answer.

## Choose where text appears

You can personalize the question text, subtitle, information message, fine print, placeholder, scale endpoints, matrix row labels, and an action link’s text or address. For an action, fill in both **Action link text** and **Action link URL**. The rendered address must be an absolute HTTP or HTTPS URL. Try it with a missing value before publishing.

Answer choices keep the wording you entered. To make part of an answer clickable, see [put a link inside an answer](/docs/questions/links-in-answer-options.md).
