# Discourse Surveys

**URL:** https://meta.discourse.org/t/discourse-surveys/308679
**Category:** Plugin
**Tags:** official, experimental, surveys
**Created:** [May 20, 2024, 9:46am UTC](https://meta.discourse.org/t/discourse-surveys/308679 "2024-05-20T09:46:58Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [May 20, 2024, 9:46am UTC](https://meta.discourse.org/t/discourse-surveys/308679/1 "2024-05-20T09:46:58Z")

</div>

| | | |
| --- | --- | --- |
| :discourse2: | **Summary** | **Discourse Surveys** plugin allows you to create surveys directly within your Discourse forum posts using simple Markdown syntax. |
| 🛠 | **Repository Link** | [https://github.com/discourse/discourse-surveys](https://github.com/discourse/discourse-surveys) |
| 📖 | **Install Guide** | [How to install plugins in Discourse](https://meta.discourse.org/t/install-plugins-in-discourse/19157) |

The Discourse Surveys Plugin allows you to create surveys directly within your Discourse forum posts using simple Markdown syntax. The plugin currently supports a variety of question types such as radio buttons, checkboxes, dropdowns, number inputs, text areas, star ratings, and thumbs up/down ratings.

## Features

- **7 Different Field Types** : Radio buttons, checkboxes, dropdowns, text areas, number selection, star ratings, and thumbs up/down

- **Required/Optional Fields** : Mark fields as required to ensure completion

- **Emoji Support** : Use emojis in your survey options

- **Markdown Support** : Rich text formatting in questions and options

- **User Authentication** : Automatic login prompts for anonymous users

- **Response Tracking** : Prevents duplicate submissions from the same user

- **Permission Aware** : Respects topic and category permissions

- **Mobile Responsive** : Works seamlessly on all devices

## Usage

### Basic Survey Structure

All surveys must be wrapped in `[survey]` tags:

```markdown

[survey name="my-survey" title="Customer Feedback Survey"]

<!-- Survey fields go here -->

[/survey]

```

### Survey Attributes

- `name`: Unique identifier for the survey (defaults to “survey”)

- `title`: Optional title displayed at the top of the survey

- `public`: Set visibility (future feature)

- `status`: Survey status (future feature)

### Field Types

#### 1. Radio Buttons (Single Choice)

```markdown

[radio question="What is your favorite color?"]

- Red

- Blue

- Green

- Yellow

[/radio]

```

#### 2. Checkboxes (Multiple Choice)

```markdown

[checkbox question="Which features do you use? (Select all that apply)"]

- Email notifications

- Mobile app

- Desktop notifications

- API access

[/checkbox]

```

#### 3. Dropdown Selection

```markdown

[dropdown question="What is your age group?"]

- Under 18

- 18-24

- 25-34

- 35-44

- 45-54

- 55+

[/dropdown]

```

#### 4. Text Area (Long Form Text)

```markdown

[textarea question="Please provide detailed feedback:" required="false"]

[/textarea]

```

#### 5. Number Selection

```markdown

[number question="Rate this feature from 1-10:" min="1" max="10"]

[/number]

```

#### 6. Star Rating

```markdown

[star question="How would you rate your overall experience?"]

[/star]

```

#### 7. Thumbs Up/Down

```markdown

[thumbs question="Would you recommend this to others?"]

[/thumbs]

```

### Field Attributes

All field types support these attributes:

- `question`: The question text (required)

- `required`: Whether the field must be filled (`true`/`false`, defaults to `true`)

- `min`: Minimum value for number fields

- `max`: Maximum value for number fields

### Complete Example

### Basic Survey Markdown

Here is a basic example of survey Markdown including all available fields:

```plaintext
[survey name="awesome-survey-thumbs" title="Awesome Survey"]

[radio question="Choose any one option:"]
- cat
- dog
[/radio]

[checkbox question="Choose multiple options:"]
- red
- blue
- green
[/checkbox]

[dropdown question="Gender:"]
- Male
- Female
[/dropdown]

[number question="Rate this survey from 1 to 10:"]
[/number]

[textarea question="What is your feedback about xyz?" required="false"]
[/textarea]

[star question="How would you rate overall experience?"]
[/star]

[thumbs question="Were you satisfied with our services?"]
[/thumbs]

[/survey]

```

### Survey Rendering

Below is an example of how the above Markdown renders in Discourse:

 ![awesome-survey](https://global.discourse-cdn.com/meta/original/4X/8/4/3/8435f2d7f81e20727b205b4f5b5bc72a4724c553.png)

## Advanced Usage

### Using Emojis in Options

```markdown

[radio question="Choose your favorite animal:"]

- 🐈 Cat

- 🐶 Dog

- 🐦 Bird

- 🐠 Fish

[/radio]

```

### Markdown Formatting in Questions

```markdown

[radio question="Which **programming language** do you prefer?"]
- JavaScript
- Python
- Ruby
- Go
[/radio]

[checkbox question="Select your *favorite* features:"]
- Speed
- Security
- Ease of use
[/checkbox]

[textarea question="Please read our [guidelines](https://example.com) and provide feedback:"]
[/textarea]

```

Supported formatting:

- **Bold** : ` **text** `
- _Italic_: `*text*`
- ~~Strikethrough~~ : ` ~~text~~ `
- `Inline code`: ``code``
- [Links](https://example.com): `[text](url)`

### 

### Mixed Required and Optional Fields

```markdown

[survey name="mixed-survey"]

[radio question="What is your role?" required="true"]

- Developer

- Designer

- Manager

- Other

[/radio]

[textarea question="Any additional thoughts?" required="false"]

[/textarea]

[/survey]

```

## Survey Results

Currently, this plugin does not have any backend UX to view the survey results directly. Instead, you can rely on [Data Explorer](https://meta.discourse.org/t/32566?silent=true) queries to fetch and analyze survey responses. Here is an example query:

```sql
-- [params]
-- text :survey_name = survey

SELECT
  s.id,
  s.name,
  s.post_id,
  sf.question,
  COALESCE(sr.value, sfo.html) AS value,
  sr.user_id,
  sr.created_at AS responded_at
FROM
  surveys s
  JOIN survey_fields sf ON sf.survey_id = s.id
  JOIN survey_responses sr ON sr.survey_field_id = sf.id
  LEFT JOIN survey_field_options sfo ON sfo.id = sr.survey_field_option_id
WHERE
  s.name = :survey_name
ORDER BY
  s.id DESC

```

## Permissions and Security

- **Login Required** : Anonymous users must log in before submitting responses

- **One Response Per User** : Each user can only submit one response per survey

- **Topic Permissions** : Users must have read access to the topic to view surveys

- **Posting Permissions** : Users must have posting permissions in the topic to submit responses

- **Archived Topics** : Surveys in archived topics cannot accept new responses

- **Deleted Posts** : Surveys in deleted posts are no longer accessible

## Limitations

- Only one survey is allowed per post

- Survey structure cannot be modified after receiving responses

- All survey field questions must be unique within a single survey

- Survey field questions cannot be blank

## Technical Details

### Database Schema

The plugin creates four main database tables:

- `surveys`: Main survey records

- `survey_fields`: Individual fields within surveys

- `survey_field_options`: Options for choice-based fields

- `survey_responses`: User responses to survey fields

### Styling

The plugin includes responsive CSS that adapts to your theme. Custom styling can be added by targeting these CSS classes:

- `.survey` - Main survey container

- `.survey-field` - Individual field wrapper

- `.field-[type]` - Specific field type containers

- `.submit-response` - Submit button

> Last edited by @techAPJ 2026-02-04T12:32:36Z
> 
> > **Check document**
> >
> > Perform check on document:

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [May 20, 2024, 10:15am UTC](https://meta.discourse.org/t/discourse-surveys/308679/2 "2024-05-20T10:15:09Z")

</div>

So users can’t see results (unless they have rights to use query) and this is totally for admins/background staff?

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [May 20, 2024, 10:16am UTC](https://meta.discourse.org/t/discourse-surveys/308679/3 "2024-05-20T10:16:22Z")

</div>

> [@Jagster](#):
>
> this is totally for admins/background staff?

Yes, that is correct.

---

<div class="post-metadata">

### Author: ![Monikas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/monikas/32/375316_2.png) [@Monikas](https://meta.discourse.org/u/Monikas)
#### Post date: [May 22, 2024, 1:59am UTC](https://meta.discourse.org/t/discourse-surveys/308679/4 "2024-05-22T01:59:49Z")

</div>

It doesn’t feel very practical 😢

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [May 23, 2024, 3:20pm UTC](https://meta.discourse.org/t/discourse-surveys/308679/5 "2024-05-23T15:20:41Z")

</div>

Need option to publish survey results. Otherwise better to use multiple polls.

---

<div class="post-metadata">

### Author: ![ppcole](https://avatars.discourse-cdn.com/v4/letter/p/49beb7/32.png) [@ppcole](https://meta.discourse.org/u/ppcole)
#### Post date: [October 8, 2024, 4:36pm UTC](https://meta.discourse.org/t/discourse-surveys/308679/9 "2024-10-08T16:36:46Z")

</div>

Hello

The sample Markdown renders in a new Topic as per below. My Discourse is updated to the latest version.

 ![The image displays a white background with a simple gray icon, which appears to be a stylized bar chart. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/8/f/7/8f71993a4e61159597bd4ba2eca772dbc024f7af.png)

What could the the problem?

Regards

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [October 14, 2024, 6:58am UTC](https://meta.discourse.org/t/discourse-surveys/308679/10 "2024-10-14T06:58:40Z")

</div>

Hey @ppcole,

The above is what is shown in composer preview when you’re creating the survey. Once you create the topic it will render properly as expected.

---

<div class="post-metadata">

### Author: ![ppcole](https://avatars.discourse-cdn.com/v4/letter/p/49beb7/32.png) [@ppcole](https://meta.discourse.org/u/ppcole)
#### Post date: [October 14, 2024, 5:27pm UTC](https://meta.discourse.org/t/discourse-surveys/308679/12 "2024-10-14T17:27:31Z")

</div>

> [@techAPJ](#):
>
> ```plaintext
> [survey name="awesome-survey-thumbs" title="Awesome Survey"]
> 
> [radio question="Choose any one option:"]
> - cat
> - dog
> [/radio]
> 
> [checkbox question="Choose multiple options:"]
> - red
> - blue
> - green
> [/checkbox]
> 
> [dropdown question="Gender:"]
> - Male
> - Female
> [/dropdown]
> 
> [number question="Rate this survey from 1 to 10:"]
> [/number]
> 
> [textarea question="What is your feedback about xyz?" required="false"]
> [/textarea]
> 
> [star question="How would you rate overall experience?"]
> [/star]
> 
> [thumbs question="Were you satisfied with our services?"]
> [/thumbs]
> 
> [/survey]
> 
> ```

Thanks Arpit. It worked. Looking forward to enhancements

---

<div class="post-metadata">

### Author: ![satonotdead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/satonotdead/32/447830_2.png) [@satonotdead](https://meta.discourse.org/u/satonotdead)
#### Post date: [June 2, 2025, 1:29pm UTC](https://meta.discourse.org/t/discourse-surveys/308679/19 "2025-06-02T13:29:19Z")

</div>

May I know if you folks are working on this but not with actual priority?

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [June 3, 2025, 2:47am UTC](https://meta.discourse.org/t/discourse-surveys/308679/20 "2025-06-03T02:47:35Z")

</div>

It would be great to have this continue to be developed - it has masses of potential.

---

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [June 18, 2025, 8:25am UTC](https://meta.discourse.org/t/discourse-surveys/308679/21 "2025-06-18T08:25:45Z")

</div>

> [@Discourse](#):
>
> ### Survey Results
> 
> Currently, this plugin does not have any backend UX to view the survey results directly. Instead, you can rely on [Data Explorer](https://meta.discourse.org/t/32566?silent=true) queries to fetch and analyze survey responses. Here is an example query:

I found that the SQL above did pull out the results, but it wasn’t in an easy to work with format; basically it would require a tonne of transformation at the spreadsheet level to enable useful analysis.

However, with a bit of Gen AI help, I was able to produce a very sweet [Data Explorer](https://meta.discourse.org/t/32566?silent=true) query. Due to some limitations of [Data Explorer](https://meta.discourse.org/t/32566?silent=true), it isn’t possible to make it dynamic enough to cope with a variety of surveys; basically you need a bespoke query per survey.

Fortunately, Gen AI can make that pretty straight forward. Here is a sample prompt that will probably work in most Gen AI services (if you don’t have the AI plugin active) - just plugin in your survey markdown and you should be away:

> **Gen AI Prompt to Produce Tailored SQL Query for a Specific Survey**
>
> I have a survey defined in markdown format, and I need a SQL query to extract the survey results from a Discourse database using the [Data Explorer](https://meta.discourse.org/t/32566?silent=true) Plugin. The survey includes various types of questions such as radio, dropdown, star, checkbox, textarea, thumbs, and number. I want the query to output results with each user having a single row and each question having its own column. For checkbox questions, multiple responses should be concatenated into a single string.
> 
> Here is the survey markdown:
> 
> ```plaintext
> Paste your survey markdown here
> 
> ```
> 
> Here is the original query used to obtain survey results:
> 
> ```sql
> -- [params]
> -- text :survey_name = survey
> 
> SELECT s.id, s.name, s.post_id, sf.question, COALESCE(sr.value, sfo.html) AS value, sr.user_id, sr.created_at as responded_at
> FROM surveys s
> JOIN survey_fields sf ON sf.survey_id = s.id
> JOIN survey_responses sr ON sr.survey_field_id = sf.id
> LEFT JOIN survey_field_options sfo ON sfo.id = sr.survey_field_option_id
> WHERE s.name = :survey_name
> ORDER BY s.id DESC
> 
> ```
> 
> Please generate a SQL query that:
> 
> - Hardcodes the survey name.
> - Uses conditional aggregation to pivot the data, with each question as a column.
> - Utilizes `STRING_AGG` for checkbox questions to handle multiple responses.
> - Ensures the output is grouped by `user_id` and ordered by `user_id`.
> - Is formatted for readability and includes comments explaining the logic where necessary.
> 
> **Additional Guidance for [Data Explorer](https://meta.discourse.org/t/32566?silent=true) Plugin:**
> 
> - The query should be compatible with the Discourse [Data Explorer](https://meta.discourse.org/t/32566?silent=true) Plugin, which means it should not end with a semicolon.
> - Use column names like `user_id` to leverage automatic linking features within the [Data Explorer](https://meta.discourse.org/t/32566?silent=true).
> - Avoid using dynamic SQL, as the plugin does not support it.
> - Ensure the query is efficient and optimized for performance, as it may be run on large datasets.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [July 10, 2025, 2:21pm UTC](https://meta.discourse.org/t/discourse-surveys/308679/23 "2025-07-10T14:21:51Z")

</div>

This is an excellent little plugin that is surprisingly feature rich. Thanks for making it.

@nathank great job on guide to quickly building results query. That makes the whole thing even more useful 🚀 (and should be moved to the OP)

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [July 24, 2025, 8:53pm UTC](https://meta.discourse.org/t/discourse-surveys/308679/25 "2025-07-24T20:53:20Z")

</div>

I installed this on my self-hosted site to take it for a spin, and it’s quite nice indeed!

I realize this is anathema to discourse, but it would be helpful if it were possible to create surveys that can be completed anonymously, without logging in. Or at least to anonymize the results so they are not associated with specific users.

And of course yes the ability to look at the results like you can with polls without having to resort to [data explorer](https://meta.discourse.org/t/32566?silent=true) would be fantastic.

---

<div class="post-metadata">

### Author: ![sunflower](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@sunflower](https://meta.discourse.org/u/sunflower)
#### Post date: [July 28, 2025, 6:43pm UTC](https://meta.discourse.org/t/discourse-surveys/308679/27 "2025-07-28T18:43:26Z")

</div>

Yes I faced the same issue. Hopefully there is a solution.

---

<div class="post-metadata">

### Author: ![MAR](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mar/32/71419_2.png) [@MAR](https://meta.discourse.org/u/MAR)
#### Post date: [September 3, 2026, 7:38pm UTC](https://meta.discourse.org/t/discourse-surveys/308679/28 "2026-09-03T19:38:37Z")

</div>

Any updates to the survey feature?

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [September 3, 2026, 8:09pm UTC](https://meta.discourse.org/t/discourse-surveys/308679/29 "2026-09-03T20:09:25Z")

</div>

> [@MAR](#):
>
> Any updates to the survey feature?

Out of interest, what update were you hoping for?

---

<div class="post-metadata">

### Author: ![satonotdead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/satonotdead/32/447830_2.png) [@satonotdead](https://meta.discourse.org/u/satonotdead)
#### Post date: [September 3, 2026, 9:45pm UTC](https://meta.discourse.org/t/discourse-surveys/308679/30 "2026-09-03T21:45:43Z")

</div>

> [@Discourse](#):
>
> Currently, this plugin does not have any backend UX to view the survey results directly.

I think this can be shipped now to allow us to get into it and test how it works on our communities in a simple way 🙂
