Hello
I want to implement a logic where I have a form and i want the web messaging icon to load only after the user clicks on the submit button but it getting loaded with load of the page. I have tried implementing inside the on click event listener but it is giving error so i created two different script tags.
script>
document.getElementById('submitButton').addEventListener('click', function() {
const form = document.getElementById('userForm');
const formData = new FormData(form);
let result = {};
formData.forEach((value, key) => {
result[key] = value;
});
let data={
messaging:{
customAttributes:result
}
}
Genesys("subscribe", "Database.ready", function() {
console.log("Database is ready");
Genesys("command", "Database.set", data,
function(data)
{
console.log("set successfully");
console.log(data);
},
function(err){ console.error(err)});
});
document.getElementById('result').innerText = `Captured Data: ${JSON.stringify(result, null, 2)}`;
});
script type="text/javascript" charset="utf-8">
(function (g, e, n, es, ys) {
g['_genesysJs'] = e;
g[e] = g[e] || function () {
(g[e].q = g[e].q || []).push(arguments)
};
g[e].t = 1 * new Date();
g[e].c = es;
ys = document.createElement('script'); ys.async = 1; ys.src = n; ys.charset = 'utf-8'; document.head.appendChild(ys);
})(window, 'Genesys', 'https://apps.aps1.pure.cloud/genesys-bootstrap/genesys.min.js', {
environment: '',
deploymentId: ''
});