【问题标题】:Integrate Clevertap in Vuejs Web application在 Vuejs Web 应用程序中集成 Clevertap
【发布时间】:2020-05-25 09:00:37
【问题描述】:

我的任务是将clevertap 与vuejs 前端集成。但是clevertap是未定义的,如何在vuejs中声明clevertap?

clevertap.event.push("Product Viewed", {
  "Product name":"Casio Chronograph Watch",
  "Category":"Mens Accessories",
  "Price":59.99,
});

【问题讨论】:

    标签: javascript vuejs2 clevertap


    【解决方案1】:

    您可以将https://github.com/CleverTap/clevertap-web-sdk 导入到您的项目中,这将为您提供clevertap 对象,或者将以下脚本添加到您应用的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>
    

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

    这将在全局范围内创建一个clevertap 对象,您可以在您的vue 应用程序中使用window.clevertap。

    【讨论】:

      猜你喜欢
      • 2018-05-08
      • 2020-12-18
      • 2014-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-30
      • 2015-05-15
      相关资源
      最近更新 更多