变色龙 JavaScript 库
易地将变色龙加入你的产品!
Chameleon JavaScript 库是一套附在全局上的方法 chmln 用于应用程序向用户显示变色龙经验的对象.
通过国家预防机制安装
该图书馆可作为一个关于国家预防机制的软件包提供。 利用国家防范机制安装前端包装器,如Webpack或浏览器,将其安装到一个项目中:
npm install --save @chamaeleonidae/chmln
你可以拿着你的 符号 然后像标准节点.js模块一样要求 lib :
const chmln = require('@chamaeleonidae/chmln');
chmln.init('YOUR_TOKEN', { fastUrl: 'https://fast.chameleon.io/' });
前所创建的账户的说明 2022-05-21 (英语) 您必须省略快件 Url 如果你不确定, 核实您的账户特定指示 安装页面。 。 。 .
chmln.init('YOUR_TOKEN');
使用变色龙作为第一当事方(即通过
chameleon.your-product.com),第一个 联系我们 设置此选项,然后使用此自定义域的更新脚本.
chmln.init('YOUR_TOKEN', { fastUrl: 'https://chameleon.your-product.com/' }); // << CHANGE ME
使用量
首先遵循上面的安装过程. 脚本同步加载, 不会影响您的页面加载时间 .
接下来,通过发送一个独特的ID来识别您的用户(这通常与数据库中的UID匹配). Chameleon无法向用户展示经验。 你也应该 发送额外的用户数据 (例如“电子邮件地址”、“作用”)或公司数据(例如“计划类型”、“子域”),因此,您可以在适当的时间将经验瞄准正确的用户.
chmln.identify(USER.ID_IN_DB, { // REQUIRED Unique ID of each user in your database (e.g. 23443 or "590b80e5f433ea81b96c9bf6")
email: USER.EMAIL, // RECOMMENDED Used to connect data coming from various integrations
// SUGGESTED - User properties:
created: USER.SIGN_UP_DATE, // Send dates in ISO or unix timestamp format (e.g. "2017-07-01T03:21:10Z" or 1431432000)
name: USER.NAME, // We will parse this to extra first and surnames (e.g. "James Doe")
role: USER.ROLE, // Send properties useful for targeting types of users (e.g. "Admin")
logins: USER.LOGIN_COUNT, // Send any data about user engagement (e.g. 39)
project: USER.PROJECT_ID, // Send any unique data for a user that might appear in any page URLs (e.g. 09876 or "12a34b56")
// OPTIONAL - Company properties:
company: { // For B2B products, send company / account information here
uid: COMPANY.ID_IN_DB, // Unique ID of the company / account in your database (e.g. 9832 or "590b80e5f433ea81b96c9bf7")
created: COMPANY.SIGN_UP_DATE, // To enable targeting all users based on this company property
name: COMPANY.NAME, // Send any data that appears within URLs, such as subdomains (e.g. "airbnb")
trial_ends: COMPANY.TRIAL_ENDS, // Send data about key milestones (e.g. "2017-08-01T03:21:10Z")
version: COMPANY.VERSION, // If your software varies by version then this will help show the correct guidance (e.g. "1.56")
plan: COMPANY.PLAN, // Send null when no value exists (e.g. "Gold", "Advanced")
spend: COMPANY.CLV // Send other properties that will help in targeting users (e.g. sales rep, source, stage)
}
});
您可以选择跟踪用户事件:
chmln.track(PLAN_CHANGED); // Example event "PLAN_CHANGED" can be used for targeting or measuring success
chmln.track(ACTIVATED); // Having a defined activation point can be helpful for targeting onboarding experiences.