@leochaddad/capacitor-referrer
v0.0.2
Published
Get Google Play Install Referrer details in Capacitor apps
Downloads
144
Maintainers
Readme
@leochaddad/capacitor-referrer
Get Google Play Install Referrer details in Capacitor apps using the latest Google Play Install Referrer API.
This plugin allows you to retrieve attribution information about how users installed your app from Google Play Store, including referrer URLs, timestamps, and instant app launch status.
Features
- ✅ Uses the latest Install Referrer Library 2.2
- ✅ Compatible with Capacitor 7
- ✅ Full TypeScript support
- ✅ Comprehensive referrer details including server-side timestamps
- ✅ Install version tracking
- ✅ Google Play Instant detection
Platform Support
- ✅ Android: Full support
- ❌ iOS: Not supported (Install Referrer is Android/Google Play only)
- ❌ Web: Not supported
Install
npm install @leochaddad/capacitor-referrer
npx cap syncUsage
import { CapacitorReferrer } from '@leochaddad/capacitor-referrer';
async function getInstallReferrer() {
try {
const referrerDetails = await CapacitorReferrer.getReferrerDetails();
console.log('Referrer URL:', referrerDetails.referrerUrl);
console.log('Click timestamp:', referrerDetails.referrerClickTimestampSeconds);
console.log('Install timestamp:', referrerDetails.appInstallTimestampSeconds);
console.log('Install version:', referrerDetails.installVersion);
console.log('Is instant app:', referrerDetails.googlePlayInstantParam);
} catch (error) {
console.error('Error getting referrer:', error);
}
}Use Cases
- Attribution Tracking: Identify which marketing campaigns drive app installs
- Analytics: Track user acquisition sources
- A/B Testing: Measure effectiveness of different promotional strategies
- Fraud Detection: Verify legitimate install sources
API
getReferrerDetails()
getReferrerDetails() => Promise<ReferrerDetails>Retrieves the install referrer details from Google Play. Note: This method only works on Android. On iOS/Web, it will reject with an error.
Returns: Promise<ReferrerDetails>
Interfaces
ReferrerDetails
| Prop | Type | Description |
| ----------------------------------------- | -------------------- | --------------------------------------------------------------------------------------- |
| referrerUrl | string | The referrer URL of the installed package. |
| referrerClickTimestampSeconds | number | The timestamp in seconds when referrer click happened. |
| appInstallTimestampSeconds | number | The timestamp in seconds when installation began. |
| referrerClickTimestampServerSeconds | number | The timestamp in seconds when the user first opened the app after installation. |
| appInstallTimestampServerSeconds | number | The timestamp in seconds when the app installation began from the server's perspective. |
| installVersion | string | The app's version at the time when the app was first installed. |
| googlePlayInstantParam | boolean | Whether the instant experience was launched. |
