Skip to main content

Setting up Tags in Kartra

note

Tagging is not available on the Free plan, to gain access you will need to upgrade to any of our paid plans!

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 = $(e.target).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:

Kartra Dashboard1 Kartra Dashboard2

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": { // replace "XXXXXXXXXXXXX" with your trigger ID
params: {
...dataFromForm,
customField: 'Custom Field value here',
user_id: 'User ID value here',
email: 'Email value here'
}
},
"XXXXXXXXXXXX": { // replace "XXXXXXXXXXXXX" with your trigger ID
params: {
customField: 'Custom Field value here',
user_id: 'User ID value here',
email: 'Email value here'
}
}
}
}
}
};
</script>

Follow the instructions as shown on the picture below:

Code Sample

Make sure to replace customField 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:

Dev Tools

If the scribe request 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.

Kartra Dashboard3 Kartra Dashboard4

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

Kartra Dashboard4

In Zapier

Choose the action event 'Assign Tag to Lead'.

Zapier Dashboard1

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

Zapier Dashboard2 Zapier Dashboard3