Prompt
How can I embed a survey into my Vue application?
Latest observation
Aug 27, 2026 · OpenAI APIWeb search: off
There are a few common ways to embed a survey into a Vue app, depending on where the survey comes from and how much control you need.
1) Embed via iframe
If your survey provider gives you an embeddable URL, this is the simplest option.
<template>
<div class="survey-wrapper">
<iframe
:src="surveyUrl"
width="100%"
height="800"
frameborder="0"
allowfullscreen
></iframe>
</div>
</template>
<script setup>
const surveyUrl = "https://your-survey-provider.com/survey/123";
</script>
Good for:
- Fast setup
- Third-party survey tools
- Minimal code
Watch out for:
- Limited styling control
- Cross-origin restrictions
- Height/scroll issues
2) Use an embed script from the survey provider
Some tools provide a JavaScript snippet instead of an iframe. In Vue, you can load it dynamically in a component.
<template>
<div ref="surveyContainer"></div>
</template>
<script setup>
import { onMounted, ref } from "vue";
const surveyContainer = ref(null);
onMounted(() => {
const script = document.createElement("script");
script.src = "https://survey-provider.com/embed.js";
script.async = true;
script.onload = () => {
// Example only: depends on provider API
window.SurveyEmbed.render({
target: surveyContainer.value,
surveyId: "123",
});
};
document.body.appendChild(script);
});
</script>
Good for:
- Better integration than iframe
- More control over placement and appearance
3) Build your own survey component
If you want full control, create the survey directly in Vue using forms, validation, and API submission.
<template>
<form @submit.prevent="submitSurvey">
<label>
How satisfied are you?
<select v-model="answers.satisfaction">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</label>
<label>
Comments:
<textarea v-model="answers.comments"></textarea>
</label>
<button type="submit">Submit</button>
</form>
</template>
<script setup>
import { reactive } from "vue";
const answers = reactive({
satisfaction: "5",
comments: "",
});
function submitSurvey() {
console.log("Submitting:", answers);
// send to your backend with fetch/axios
}
</script>
Good for:
- Full design control
- Custom logic
- Integration with your backend
Which should you choose?
- Quickest: iframe
- Best third-party integration: script embed
- Most flexible: build it yourself
If you tell me which survey service you’re using (Typeform, Google Forms, SurveyMonkey, etc.) or whether you want to build it in Vue, I can give you a specific implementation.