Dashboard
Capacitor

Installation

Add @attriv/capacitor to your iOS or Android app.

Install the plugin

Terminal
pnpm add @attriv/capacitor

Then sync your native projects:

Terminal
npx cap sync

Initialize

Initialize once at app start (e.g. in your root component or main entry):

import { Attriv } from "@attriv/capacitor";

await Attriv.init({
  appKey: "ak_your_app_key", // from the Attriv dashboard
  apiUrl: "https://api.getattriv.com",
});
For debug/internal builds, use a test key (ak_test_… — created under App → Settings → API keys) so QA installs and opens land in the test environment instead of live stats. Ship the live key in release builds.

After init, the SDK automatically:

  • posts an install on first launch (once per device) and an open on subsequent launches — these reports also feed automatic MAU accounting
  • resolves attribution deterministic-first: App Clip click id (iOS, when App Clips are configured), then deep-link click id, then Play Install Referrer (Android), then pasteboard (iOS), with probabilistic fingerprint matching as a last resort
  • resolves deep links delivered via Capacitor's appUrlOpen (disable with autoResolveLinks: false)

Platform behavior

iOS

Two deterministic mechanisms cover different stages of the iOS funnel — App Clip handoff at click time and the pasteboard at install time. Both are opt-in and can be combined freely; probabilistic fingerprint matching always runs as the last resort and cannot be disabled. See iOS attribution for the signal overview and copy-paste recipes, including a probabilistic-only setup.

  • Pasteboard matching — how the clipboard is used for deferred deep linking is controlled by the pasteboard option (see API reference):
    • "control" (default) — no system paste prompt, ever. The install carries no clipboard data; your app offers the SDK's system paste button via Attriv.showPasteControl() (see below). On iOS < 16 this mode degrades to "read" (no prompt exists there).
    • "read" — on first launch the SDK silently probes the pasteboard and only reads it (triggering the iOS paste prompt) when it contains a URL-shaped payload from an Attriv landing page; the payload is consumed after use.
    • "both" — "read" at install, plus your app offers the paste control for users who deny the prompt.
    • "off" — no pasteboard mechanics; installs fall to fingerprint or organic.
    • Booleans are accepted for compatibility: true → "read", false → "off".
  • The paste control (consent-first) — Attriv.showPasteControl() renders a native card with your heading, your caption, and the system paste button: Apple's UIPasteControl (iOS 16+). It's a system-rendered control that hands your app the clipboard contents only when the user explicitly taps it — the tap is the consent, so no iOS paste prompt ever fires, and the system draws the button itself (localized "Paste" label, plus the source app's icon so users see where the content came from). It requires no entitlements or Info.plist changes. Content that doesn't carry an Attriv payload is validated and discarded on-device — nothing unrelated is ever transmitted.
    // Tap outcomes arrive via onPasteClaim — the show promise resolves on
    // render, since a skipped card is normal and settles nothing.
    Attriv.onPasteClaim(({ claimed, attribution }) => {
      if (claimed) {
        // attribution is the updated attribution; route to link.data?.$deeplink_path
      }
    });
    
    // On your first screen, after init:
    const attribution = await Attriv.getAttribution();
    if (attribution.matchType === "organic") {
      await Attriv.showPasteControl({
        title: "Open the link that brought you here",
        caption: "Your link is waiting on the clipboard — only the link is read.",
      });
    }
    

    Show it only while attribution is organic and hide it once attributed; a skipped button stays retryable across launches (shown: false, reason: "no_url" when there is nothing URL-shaped on the clipboard). Copy guidance: frame it as an offer ("open your link"), never a permission ("allow us to read your clipboard"), and align the title with what your campaign promised.
  • Device id persistence — the Attriv device id is mirrored into the keychain, which — unlike UserDefaults — survives app reinstalls. A reinstall re-attributes against the same device id instead of counting as a new organic install.
  • App Clips — when your app is App Clip-configured, the first launch reads the click id your App Clip wrote to the shared App Group container and claims it deterministically (pass the App Group identifier via appClipAppGroup in init). The invocation-URL fallback lands via the standard appUrlOpen resolve flow — no extra wiring.

Android

  • Play Install Referrer — on first launch the SDK reads the Install Referrer and extracts the attriv_click_id parameter to match the install to a click.

Subscribe to resolved deep links to route the user into your app:

const handle = Attriv.onDeepLink(({ link }) => {
  const path = link.data?.$deeplink_path;
  if (path) router.push(path);
});

// later: handle.remove()

If you forward URLs yourself instead of relying on appUrlOpen, pass autoResolveLinks: false to init and call Attriv.resolve({ url }) manually.

Verify

Fetch the attribution for this device:

const attribution = await Attriv.getAttribution();
// { attributed: true, matchType: "deeplink", link: { … }, deviceId: "…" }

matchType is one of deeplink, referrer, pasteboard, fingerprint, appclip — or organic when no click was matched.