Skip to main content

Play Gates

Submit Event

You can listen to the playgate:submit event to get notified when a play gate form is submitted. The event will receive the Play Gate id and the form values as arguments, so you can do whatever you want with the form values on your side.

player.on('playgate:submit', (playGateId, formValues) => {
console.log(`Play Gate ${playGateId} was submitted with values:`, formValues);
});

Show Event

If you want to do something when a play gate is shown, you can listen to the playgate:show event. The event will receive the Play Gate id as an argument.

player.on('playgate:show', (playGateId) => {
console.log(`Play Gate ${playGateId} was shown.`);
});

Custom Endpoint

You are able to send the form values to your own endpoint by using fetch or any other method that you prefer.

player.on('playgate:submit', (playGateId, formValues) => {
fetch('https://your-custom-endpoint.com', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(formValues),
mode: 'no-cors', // add this line if request domain is different
})
.then((response) => {
console.log('Form submitted successfully!');
})
.catch((error) => {
console.error('Error submitting form:', error);
});
});

Form values will usually look like this, but it depends on the fields that you have configured on your Play Gate:

{
"email": "hi@vidalytics.com",
"name": "Customer Name",
"phone": "111-111-1111"
}