Web 基本集成
SDK 统计
Open Source Github Repo: https://github.com/BranchMetrics/web-branch-deep-linking
SDK Size: 50kb
Speed: Median 80ms to 250ms
iOS 14 智能追踪预防警告
在 Safari iOS 14上,您可能会看到 “branch.io” 被 Safari 屏蔽并有新的可见性。请知悉这是正常的,且仅表示来自 branch.io 的 cookie 被阻止。网页功能或追踪均不会受到影响。我们使用其他域来管理 cookie。
要求
该 SDK 需要本地浏览器 Javascript,并且已经在所有具有 sessionStorage 功能的现代浏览器中进行了测试。无需第三方库即可使用 SDK,因为它是100%原生 Javascript。
浏览器特定支持
Chrome | Firefox | Safari | IE |
---|---|---|---|
✔ | ✔ | ✔ | 9、10、11 |
配置 Branch
- Configure the default link settings for your app

初始化 Branch
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<script>
// load Branch
(function(b,r,a,n,c,h,_,s,d,k){if(!b[n]||!b[n]._q){for(;s<_.length;)c(h,_[s++]);d=r.createElement(a);d.async=1;d.src="https://cdn.branch.io/branch-latest.min.js";k=r.getElementsByTagName(a)[0];k.parentNode.insertBefore(d,k);b[n]=h}})(window,document,"script","branch",function(b,r){b[r]=function(){b._q.push([r,arguments])}},{_q:[],_v:1},"addListener applyCode autoAppIndex banner closeBanner closeJourney creditHistory credits data deepview deepviewCta first getCode init link logout redeem referrals removeListener sendSMS setBranchViewData setIdentity track validateCode trackCommerceEvent logEvent disableTracking qrCode".split(" "), 0);
// init Branch
branch.init('key_live_YOUR_KEY_GOES_HERE');
</script>
</head>
<body></body>
</html>
- Apply script to the
<Head/>
element of the HTML - Change
key_live_YOUR_KEY_GOES_HERE
to match your Branch Dashboard - If you'd like to use a specific version of the SDK, point to https://cdn.branch.io/branch-x.xx.x.min.js (e.g. https://cdn.branch.io/branch-2.47.1.min.js) rather than https://cdn.branch.io/branch-latest.min.js when initializing.
转义 Key 和值
WebSDK 版本< = 2.48.0的 Journeys 链接数据(从 Journeys 事件处理程序返回的数据)将包含转义的 key 和值。用于转义的字符包括", ', &, <,和> 。这些字符将转义为其相应的 HTML 实体。另外,key 和值中的 URL 将进行 URI 编码。
使用 WebSDK> = 2.49的开发人员将注意到,Journeys 链接数据中的值使用与上述相同的规则进行转义。Key 将不会被转义。
Updated 3 months ago