How to Change Attached Video Dynamically

Let’s assume you want to collect feedback on a photography video course hosted on your YouTube channel. The course consists of 78 videos, and you want to embed each video on a Voiceform page to gather user feedback. While creating 78 individual questions is an option, it would be too time-consuming. Instead, we’ll show you how to use dynamic variables to achieve this efficiently.

Step 1: Setting Up the Dynamic Variable

  1. Create a survey in Voiceform.
  2. Navigate to the Settings section and create a new dynamic variable called video_link.
  3. This variable will be used to pass the video link dynamically through metadata.

Step 2: Adding a Feedback Question

  1. Add a new question to your survey.
  2. Use the text: "Please share your feedback about the video."
  3. In the right-side panel, scroll to the Attachment section and locate the Video Attachment option.
  4. Select the Embed tab.

Step 3: Embedding the YouTube Video

  1. Choose the YouTube embedding option.

  2. Add the following embedding code to the text box:

    <iframe 
        width="560" 
        height="315" 
        src="https://www.youtube.com/embed/dwrGAoZIrOw?si=sMAFSvR011a0jD4V" 
        title="YouTube video player" 
        frameborder="0" 
        allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" 
        referrerpolicy="strict-origin-when-cross-origin" 
        allowfullscreen>
    </iframe>
    
  3. This code attaches a specific video to your question. However, to make it dynamic, you need to replace the src attribute with the video_link variable.

Step 4: Making the Video Dynamic

  1. Modify the src attribute in the embedding code to include the video_link dynamic variable. The updated code will look like this:

    <iframe 
        width="560" 
        height="315" 
        src="{{video_link}}" 
        title="YouTube video player" 
        frameborder="0" 
        allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" 
        referrerpolicy="strict-origin-when-cross-origin" 
        allowfullscreen>
    </iframe>
    
  2. This ensures the video link is dynamically replaced based on the variable passed when the survey is accessed.

Step 5: Sharing the Survey with Dynamic Video Links

  1. When sharing your survey, include the video link as part of the URL by appending it as a query parameter.

  2. For example:

    https://app.voiceform.com/to/my_survey_hash?video_link=https://www.youtube.com/embed/3k2lFp47e6A?si=0hk3GcHQISlGEyun
    

This setup dynamically embeds the specified video into the survey, allowing users to provide feedback on each video seamlessly without creating separate questions for all 78 videos.