I see that I can add custom code to the body. I’m adding some Clevertap code to track analytics:
<script type="text/javascript">var clevertap = {event:[], profile:[], account:[], onUserLogin:[], notifications:[], privacy:[]};
// replace with the CLEVERTAP_ACCOUNT_ID with the actual ACCOUNT ID value from your Dashboard -> Settings pageclevertap.account.push({"id": "CLEVERTAP_ACCOUNT_ID"});
clevertap.privacy.push({optOut: false}); //set the flag to true, if the user of the device opts out of sharing their dataclevertap.privacy.push({useIP: false}); //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' : 'http://static. clevertap. com') + '/js/a.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wzrk, s);
})();
</script>
following the instructions here support wix. com/en/article/embedding-custom-code-to-your-site#working-with-third-party-code, I can add this code to my HEAD and see that it runs.
Now I want to track user events, which are tied into interactions that I have programmed in the Wix Velo javascript language.
I want to be able to run this code when the page loads:
clevertap.event.push(“Page Viewed”, {
“name”: “XYZ”,
“activeCount”: 33,
“Status”: “open”,
});
and I want to run this code when a button is clicked on:
clevertap.event.push(“Button clicked”, {
“name”: “Ab”,
“ping”: “up”,
});
But when I run this, I get clevertap is not defined
I also tried accessing the window object from Velo code, but I discovered that was a no-go. I tried using the wixWindow too, but I wasn’t sure how to get to the (externally loaded) clevertap object.
The solution for implementing JS here is incomplete because it can only load HEAD and BODY javascript and does not seem to be able to be hooked up to tracking events (like clicks on the page). Am I missing something? Is there a better way to do this?