1

I am having a task to integrate clevertap with vuejs frontend. but clevertap is undefined, how can i declare clevertap in vuejs?

clevertap.event.push("Product Viewed", {
  "Product name":"Casio Chronograph Watch",
  "Category":"Mens Accessories",
  "Price":59.99,
});
Chan Yoong Hon
  • 1,592
  • 7
  • 30
  • 71

1 Answers1

0

You could either import https://github.com/CleverTap/clevertap-web-sdk into your project which will give you the clevertap object or alternatively add the following script to your app's HTML

<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 page
clevertap.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 data
clevertap.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>

Source: https://developer.clevertap.com/docs/web-quickstart-guide

This will create a clevertap object globally and you can use window.clevertap within your vue app.

Victor Fernandes
  • 386
  • 1
  • 4
  • 15