首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >集成userVoice开发工具包与meteor

集成userVoice开发工具包与meteor
EN

Stack Overflow用户
提问于 2014-12-14 05:23:26
回答 1查看 211关注 0票数 1

我有userVoice.js

代码语言:javascript
复制
Meteor.startup(function() {
  // Include the UserVoice JavaScript SDK (only needed once on a page)
  UserVoice=window.UserVoice||[];(function(){var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/cOADa8czIXBWdvlpMDtTVg.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})();

  //
  // UserVoice Javascript SDK developer documentation:
  // https://www.uservoice.com/o/javascript-sdk
  //

  //var feedbackEmail = Meteor.user().emails[0].address;

  // Set colors
  UserVoice.push(['set', {
    accent_color: '#448dd6',
    trigger_color: 'white',
    trigger_background_color: 'rgba(46, 49, 51, 0.6)'
  }]);

  // Identify the user and pass traits
  // To enable, replace sample data with actual user traits and uncomment the line
  UserVoice.push(['identify', {
    //email:      feedbackEmail, // User’s email address
    //name:       'John Doe', // User’s real name
    //created_at: 1364406966, // Unix timestamp for the date the user signed up
    //id:         123, // Optional: Unique id of the user (if set, this should not change)
    //type:       'Owner', // Optional: segment your users by type
    //account: {
    //  id:           123, // Optional: associate multiple users with a single account
    //  name:         'Acme, Co.', // Account name
    //  created_at:   1364406966, // Unix timestamp for the date the account was created
    //  monthly_rate: 9.99, // Decimal; monthly rate of the account
    //  ltv:          1495.00, // Decimal; lifetime value of the account
    //  plan:         'Enhanced' // Plan name for the account
    //}
  }]);

  // Add default trigger to the bottom-right corner of the window:
  // UserVoice.push(['addTrigger', { mode: 'contact', trigger_position: 'bottom-right' }]);

  // Or, use your own custom trigger:
  UserVoice.push(['addTrigger', '#submitFeedback', { mode: 'contact' }]);

  // Autoprompt for Satisfaction and SmartVote (only displayed under certain conditions)
  UserVoice.push(['autoprompt', {}]);
});

它有时会运行,但有时我会收到一个客户端错误:

代码语言:javascript
复制
 Uncaught TypeError: Cannot read property 'getAttribute' of null

不知道我是不是运行错了脚本。我也不确定如何在Meteor中加载额外的脚本以及以什么顺序加载

EN

回答 1

Stack Overflow用户

发布于 2015-01-14 01:55:06

刚刚在我的meteor应用程序上实现了uservoice,和你的想法类似,但我想你忘了取消对用户信息的注释。

代码语言:javascript
复制
Deps.autorun(function() {
 var user = Meteor.user();
 if(user) {
   //uservoice code
 }

现在是识别用户的东西:

代码语言:javascript
复制
UserVoice.push(['identify', {
     email:      user.profile.email, // User’s email address
     name:       user.fullName(), // User’s real name
     id:         user._id, // Optional: Unique id of the user (if set, this should not change)
     type:       'user', // Optional: segment your users by type       
}]);

到目前为止,它是有效的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27463766

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档