Integrating clevertap events in Javascript

140 Views Asked by At

I have a requirement where I need to push an event to push an event to clevertap, and add a listener to it which is supposed to return a set of data to me. As per the documentation, I have initialised the clevertap as below:

var clevertap = {
    event: [],
    profile: [],
    account: [],
    onUserLogin: [],
    notifications: [],
};
clevertap.account.push({ id: "MY_CT_ID" });
(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);
})();

I am able to push events, but how do I listen to the pushed events? I tried the following:

document.addEventListener("Homepage Open", function (event) {
            console.log("fbjndfgneirgnreui");
        });

But it doesn't seem to be working. Any help is greatly appreciated!

Edit - Referring to the following documentation: https://developer.clevertap.com/docs/web-overview

0

There are 0 best solutions below