Web SDK
Installation
Add “Download” or “Open in App” buttons to your website with Universal Links support and automatic click tracking.
Prerequisites
You need a publishable key (pk_live_) to use the web SDK. Create one after setting up a custom domain.
Quick start
<script src="https://api.riftl.ink/sdk/rift.js"></script>
<script>
Rift.init("pk_live_YOUR_KEY", { domain: "go.yourcompany.com" });
</script>
<!-- Just a normal link. Click tracking happens automatically. -->
<a href="https://go.yourcompany.com/summer-sale">Get the App</a>Pass your custom domain to Rift.init(). The SDK auto-tracks clicks on any link pointing to that domain — no attributes or event handlers needed.
API Reference
Rift.init(publishableKey, opts?)
Initializes the SDK with your publishable key. Pass domain to enable automatic click tracking on all links pointing to that domain.
| Param | Type | Description |
|---|---|---|
| publishableKey | string | Your publishable key (starts with pk_live_). Required. |
| opts.domain | string | Your custom link domain (e.g., go.yourcompany.com). Enables auto-tracking. |
| opts.baseUrl | string | API base URL. Default: https://api.riftl.ink |
Rift.click(linkId, opts?)
Manually record a click event for programmatic use cases. Not needed when using domain-based auto-tracking. Fire-and-forget via sendBeacon — does not block navigation.
| Param | Type | Description |
|---|---|---|
| linkId | string | The link ID to record a click for. |
| opts.domain | string | Custom domain for the clipboard URL. Defaults to the init domain. |
Rift.getLink(linkId, opts?)
Fetches link data without navigating. Returns a Promise with the link metadata, destinations, and agent context. Useful for building custom UI.
const link = await Rift.getLink("summer-sale");
console.log(link.agent_context); // { action, cta, description }
console.log(link._rift_meta); // { status, tenant_domain, ... }How it works
- The download button is a plain
<a href="https://go.yourcompany.com/link-id">tag pointing to your Universal Link domain. - When the user clicks the link, the SDK detects it matches your domain and auto-fires a
sendBeacontoPOST /v1/attribution/clickto record the click. This is fire-and-forget and does not block navigation. - App installed: iOS/Android intercepts the tap via Universal Links / App Links and opens the app directly. The landing page never loads.
- App not installed: The browser navigates to the landing page, which shows a branded “Get the App” page with an App Store / Play Store button. The landing page also copies the link URL to clipboard (iOS) for deferred deep linking.