Adding a cookie to a marketo landing page
I need to add a cookie to a marketo landing page. I have the script but I am not sure how to call to it on successful form submit. Here is the script:
function writeCookie (cName, vals) {
var cVal = vals.FirstName+'|' +
vals.LastName +'|' +
vals.Email +'|' +
vals.Company +'|' +
vals.Role__c +'|' +
vals.Phone +'|' +
vals.Country +'|' +
vals.State;
var tos = ['Double_Opt_in_Compliant__c', 'doubleOptinCompliantCanada', 'termsofService'];
$.each(tos, function(i, v) {
if (vals[v]) {
cVal += '|' + v + '|' + vals[v];
return false;
}
if (i == tos.length - 1) {
cVal += '||';
}
});
var expire = new Date();
expire.setDate(expire.getDate() + 30);
document.cookie = cName + "=" + encodeURIComponent(cVal) + ";expires=" + expire.toString() + "; path=/";
}
the cookie is "couchbase-download"
How can I implement this?