Hello,
I am trying to use this simple JS event trigger script for CleverTap (A product analytics tool) but can’t seem to get this code to fire. It is working fine within JSFiddle, but not working when using the JS action in a Workflow, as I want to trigger this event on button clicks.
Here is the code I am trying to use:
var name = "Full Name";
var email = "some@email.com";
var identity = 1;
clevertap.onUserLogin.push({
"Site": {
"Name": name,
"Identity": identity,
"Email": email,
}
})
This of course requires the CleverTap code to be loaded on the page and I am doing that from the global “Custom code” option. If needed, here is the global custom code used by CleverTap:
<script type="text/javascript">
var clevertap = {event:[], profile:[], account:[], onUserLogin:[], notifications:[], privacy:[]};
clevertap.spa = true;
clevertap.account.push({"id": "???-????-????"});
clevertap.privacy.push({optOut: false}); //set the flag to true, if the user of the device opts out of sharing their data
clevertap.privacy.push({useIP: true}); //set the flag to true, if the user agrees to share their IP data
(function () {
var wzrk = document.createElement('script');
wzrk.type = 'text/javascript';
wzrk.async = true;
wzrk.src = ('https:' == document.location.protocol ? 'https://d2r1yp2w7bby2u.cloudfront.net' : 'https://static.clevertap.com') + '/js/clevertap.min.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wzrk, s);
})();
</script>
Would appreciate it if anyone have any suggestions or have used something similar before and could share some tips.
Thanks!