@capgo/capacitor-install-referrer

中文文档
8.1.15发布于 2026/10/15MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 6.1万

Capacitor plugin for reading Google Play install referrer and Apple AdServices attribution.

原始使用文档
文档目录11 节
  1. ➡️ Get started for free
  2. Key features
  3. Platform behavior
  4. Install
  5. Usage
  6. Compatibility
  7. API
  8. getReferrer(...)
  9. GetReferrer(...)
  10. getPluginVersion()
  11. Interfaces

@capgo/capacitor-install-referrer

Find out where an install came from: Google Play Install Referrer on Android and Apple AdServices attribution on iOS, behind one call. Attribute installs to campaigns without a full MMP SDK.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-install-referrer in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-install-referrer to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-install-referrer for Capacitor apps

Key features

  • One call: getReferrer() returns native install attribution details.
  • Android: reads the Google Play Install Referrer, including the referrer string and timestamps.
  • iOS: returns an Apple AdServices attribution token.
  • Apple Search Ads: set fetchAppleAttribution to also fetch Apple's attribution payload.
  • Drop-in alias: GetReferrer() for code written for older referrer plugins.
  • Platforms: iOS and Android. Not available on web.

Capacitor plugin for install attribution. Android reads Google Play Install Referrer, and iOS uses Apple AdServices attribution tokens with optional Apple Search Ads attribution lookup.

Compatible with Capacitor 8.

Platform behavior

  • Android returns the Play install referrer string, click timestamp, install timestamp, and instant experience flag.
  • iOS returns an AdServices attribution token. Set fetchAppleAttribution to true to ask Apple for the attribution payload directly from native code.
  • iOS does not provide a generic App Store install referrer equivalent to Google Play. Apple AdServices covers Apple Search Ads attribution.
  • Web is unavailable and rejects the call.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-install-referrer` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

bun add @capgo/capacitor-install-referrer
bunx cap sync

Usage

import { InstallReferrer } from '@capgo/capacitor-install-referrer';

const result = await InstallReferrer.getReferrer();

if (result.platform === 'android') {
  console.log(result.referrer);
}

if (result.platform === 'ios') {
  console.log(result.attributionToken);
}

Fetch the Apple attribution payload from iOS native code:

const result = await InstallReferrer.getReferrer({
  fetchAppleAttribution: true,
  appleAttributionRetryCount: 3,
  appleAttributionRetryDelayMs: 5000,
});

console.log(result.appleAttribution);

GetReferrer() is also available as a deprecated compatibility alias for apps migrating from cap-play-install-referrer.

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8..v8..Yes
v7..v7..On demand
v6..v6..No

API

Base API for retrieving install referrer and attribution details.

getReferrer(...)

getReferrer(options?: GetReferrerOptions | undefined) => Promise<GetReferrerResult>

Returns native install attribution details.

Android reads the Google Play Install Referrer API. iOS returns an Apple AdServices attribution token and can optionally fetch Apple's attribution payload.

ParamType
optionsGetReferrerOptions

Returns: Promise<GetReferrerResult>

Since: 8.0.0


GetReferrer(...)

GetReferrer(options?: GetReferrerOptions | undefined) => Promise<GetReferrerResult>

Backward-compatible alias for plugins inspired by cap-play-install-referrer.

ParamType
optionsGetReferrerOptions

Returns: Promise<GetReferrerResult>

Since: 8.0.0


getPluginVersion()

getPluginVersion() => Promise<PluginVersionResult>

Returns the platform implementation version marker.

Returns: Promise<PluginVersionResult>

Since: 8.0.0


Interfaces

GetReferrerResult

Install referrer and attribution details returned by the native platform.

PropTypeDescriptionSince
platformstringPlatform that produced the result. Android returns android; iOS returns ios.8.0.0
referrerstringAndroid only. Raw Google Play install referrer string.8.0.0
clickTimestampSecondsnumberAndroid only. Client-side click timestamp in seconds.8.0.0
installBeginTimestampSecondsnumberAndroid only. Client-side install begin timestamp in seconds.8.0.0
googlePlayInstantParambooleanAndroid only. True when the user launched your app's instant experience.8.0.0
attributionTokenstringiOS only. Apple AdServices attribution token. Send this token to your backend, MMP, or Apple's AdServices API within its TTL.8.0.0
appleAttributionAppleAttributionRecordiOS only. Apple AdServices attribution payload when fetchAppleAttribution is true.8.0.0

AppleAttributionRecord

Install attribution values returned by Apple AdServices.

Apple may add fields over time, so unknown keys are preserved.

PropTypeDescriptionSince
attributionbooleanTrue when Apple found a matching Apple Search Ads attribution record.8.0.0

GetReferrerOptions

Options for reading install attribution.

PropTypeDescriptionDefaultSince
fetchAppleAttributionbooleaniOS only. When true, the plugin sends the AdServices attribution token to Apple and returns the attribution payload in appleAttribution. Leave this false when you want to send attributionToken to your own backend or MMP.false8.0.0
appleAttributionRetryCountnumberiOS only. Number of times to retry Apple's attribution endpoint after a 404 response. Apple can return 404 when the token is valid but attribution data is not ready yet.38.0.0
appleAttributionRetryDelayMsnumberiOS only. Delay between Apple attribution retries, in milliseconds.50008.0.0

PluginVersionResult

Plugin version payload.

PropTypeDescription
versionstringVersion identifier returned by the platform implementation.

版本与发布记录

@capgo/capacitor-install-referrer 共发布 16 个版本,首次发布于 2026/05/06;过去 12 个月发布了 16 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.1.15latest2026/10/1525 天前
8.1.142026/10/1327 天前
8.1.132026/10/091 个月前
8.1.122026/10/081 个月前
8.1.112026/09/161 个月前
8.1.102026/09/151 个月前

关于 @capgo/capacitor-install-referrer 的常见问题

@capgo/capacitor-install-referrer 是什么?

Capacitor plugin for reading Google Play install referrer and Apple AdServices attribution.

如何安装 @capgo/capacitor-install-referrer?

在项目目录运行 npm install @capgo/capacitor-install-referrer,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-install-referrer 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-install-referrer 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-install-referrer 可以商用吗?

@capgo/capacitor-install-referrer 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-install-referrer 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-install-referrer 在 2026/10/09 – 2026/11/07 这 30 天内被下载 61,497 次,日均约 2,050 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-install-referrer 还在维护吗?

最新版本 8.1.15 发布于 2026/10/15(25 天前);至今共发布 16 个版本,其中过去 12 个月发布了 16 个;首次发布于 2026/05/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。