javascripttypeform

Retrieve typeform form data in embed mode


I've seen that I can hook up to the onSubmit event with the following code:

typeformEmbed.makeWidget(this.$el, 'https://pptt.typeform.com/to/S70gmy', {
      onSubmit: event => {
        console.log('event.onSubmit', event)
      }
    })

However, that event is undefined, like Typeform, it only sends the event out without the form data

Then there's this way:

window.addEventListener('message', function(event){
      if(event.data.type == 'form-submit')
        // your business logic here
    }, false);

But I can't find the form data there.

Is this possible? I'd like to send the typeform data elsewhere, or append it to another normal form that I have.


Solution

  • Looks like you are using Typeform Embed SDK.

    Different ways to do this:

    const reference = typeformEmbed.makePopup(
      'https://admin.typeform.com/to/PlBzgL',
      {
        onSubmit: function (event) {
          console.log(event.response_id)
        }
      }
    )
    

    I hope it helps. We are looking at making improvements at this SDK in the near future.

    (edit: 25 August 2020, the Embed SDK now supports this usecase)