To send data from the form to triggers, insert this code in the footer of the page with the form:

<script>
$('form').on('submit', (e) => {
var formData = $('form').serialize();
var key = 'vidalytics_kartra_form_data';
if(formData) {
var formData = formData.split('&');
var formDataParse = formData.map(elem => {
var decodeStr = decodeURIComponent(elem);
var value = decodeStr.replace(/\+/g, " ");
return value;
})
var formDataSplit = formDataParse.map(value => value.split('='));
var formDataObject = Object.fromEntries(formDataSplit);

localStorage.setItem(key, JSON.stringify(formDataObject));
}
})
</script>

The code above needs to go here:

To make the tagging via form in Kartra work, you will need to add some additional code to your video embed code (if the video is on the same page as the form, it'll work as well):

<script type="text/javascript">
var key = 'vidalytics_kartra_form_data';
var data = localStorage.getItem(key);
var dataFromForm;
if(data) {
dataFromForm = JSON.parse(data);
}

var vidalyticsCustomSettings = {
plugins: {
trigger: {
triggers: {
"XXXXXXXXXXXXX": {
params: {
...dataFromForm,
customField: 'Custom Field Value',
user_id: 'Custom User ID',
email: 'Email'
}
},
"XXXXXXXXXXXX": {
params: {
customField: 'Custom Field Value',
user_id: 'Custom User ID',
email: 'Email'
}
}
}
}
}
};
</script>

Follow the instructions as shown on the picture below:

(click to enlarge)

Make sure to replace customField and / or user_id with the actual IDs that you're collecting on the form. E.g.: 'email'.

Check Your Tags

To check if the tags are firing, you can follow the next steps in your browser:

Developer Tools -> Network -> file Scribe (there will be a couple of them) -> POST request -> it will be sending "Vidalytics.Player.EVENT_TRIGGER"

You will also find the sent data there. It will look like this:

If the Scribe file is sent, then the triggers are working.

In Kartra

Make sure that you have a list set up, and the tags you want to add to your contacts already created in your Kartra account.

Also, make sure all the contacts that opt in through your form are added to the same list you'll be plugging into Zapier.

In Zapier

Choose the action event 'Assign Tag to Lead'.

Make sure your Kartra tag matches the tag you set up inside Vidalytics before, so you know you're tracking the same times.

Did this answer your question?