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.
Looks like you are using Typeform Embed SDK.
Different ways to do this:
have a webhook on this form, it will get pinged when the form is submitted and there you will have access to the whole payload of the answer. Doc
on the onSubmit action, get the response id and call Typeform Responses API to find the corresponding response.
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)