Search code examples
javascriptwistia

Wistia Javascript API - conversion event to redirect to a confirmation page


I'm using Wistia's Turnstile to capture e-mail in the end of a video. The problem is that I would like to redirect to another page after the user clicks submit. The message would have a request to check the e-mail to confirm the double opt-in.

I have tried using 2 Embed types with no sucess.

IFrame:

<iframe src="//fast.wistia.net/embed/iframe/7zu6ze7v40?videoFoam=true" allowtransparency="true" frameborder="0" scrolling="yes" class="wistia_embed" name="wistia_embed" allowfullscreen mozallowfullscreen webkitallowfullscreen oallowfullscreen msallowfullscreen id="my_wistia_video"></iframe>
<script src="//fast.wistia.net/assets/external/iframe-api-v1.js"></script>
<script>
  wistiaEmbed = document.getElementById("my_wistia_video").wistiaApi;
  wistiaEmbed.bind("conversion", function(type, val) {
  window.location.href == "http://the_page";
});
</script>

API:

<div id="wistia_7zu6ze7v40" class="wistia_embed" style="width:640px;height:508px;">&nbsp;</div>
<script charset="ISO-8859-1" src="//fast.wistia.com/assets/external/E-v1.js"></script>
<script>
  wistiaEmbed = Wistia.embed("7zu6ze7v40", {
    videoFoam: true
  });
  wistiaEmbed.bind("conversion", function(type, val) {
    window.location.href == "http://the_page";
  });
</script>

Any hints or advices?


Solution

  • I couldn't find the answer of my question but I solved the problem in another way that may be even better depending on the case.

    The idea is to include a form on the page that the video is and only show the form when the video ends. The div of the form must have a "display: none;" and this code will make it appear when the video ends:

    <script>
      wistiaEmbed = document.getElementById("my_wistia_video").wistiaApi;
      wistiaEmbed.bind("end", function() {  
        document.getElementById("div_id").style.display = 'block';
      });
    </script>
    

    In this case, I stopped using turnstile. I'm using call to action although I believe that editing the video could be another solution.