Getting Started
Dieser Inhalt ist in Ihrer Sprache noch nicht verfügbar.
-
Install the package
Terminal-Fenster npm i @capgo/capacitor-rudderstackTerminal-Fenster pnpm add @capgo/capacitor-rudderstackTerminal-Fenster yarn add @capgo/capacitor-rudderstackTerminal-Fenster bun add @capgo/capacitor-rudderstack -
Sync native projects
Terminal-Fenster npx cap syncTerminal-Fenster pnpm cap syncTerminal-Fenster yarn cap syncTerminal-Fenster bunx cap sync -
Collect your RudderStack credentials You need your RudderStack
writeKeyand, in most setups, yourdataPlaneUrl.
Initialize RudderStack
Section titled “Initialize RudderStack”Initialize the SDK as early as practical in your app startup:
import { RudderStack } from '@capgo/capacitor-rudderstack';
await RudderStack.initialize('YOUR_WRITE_KEY', { dataPlaneUrl: 'https://your-dataplane.rudderstack.com', trackLifecycleEvents: true, recordScreenViews: false, logLevel: RudderStack.LogLevel.INFO,});The plugin keeps the Cordova-style signature, so existing Rudder Cordova integrations can usually migrate with minimal JavaScript changes.
Identify users and track events
Section titled “Identify users and track events”await RudderStack.identify('user_123', { email: 'user@example.com', plan: 'pro',});
await RudderStack.track('Checkout Started', { value: 49, currency: 'EUR',});
await RudderStack.screen('Checkout', { step: 'shipping',});You can also use group() and alias() when your data model depends on account-level grouping or identity transitions.
Per-call options
Section titled “Per-call options”RudderStack supports external identifiers and destination-specific toggles:
await RudderStack.track( 'Purchase Completed', { orderId: 'ord_123', total: 99, }, { externalIds: { brazeExternalId: 'user_123', }, integrations: { All: true, Amplitude: false, }, },);Delivery and privacy controls
Section titled “Delivery and privacy controls”Useful operational methods:
await RudderStack.putDeviceToken('PUSH_TOKEN');await RudderStack.putAdvertisingId('ADVERTISING_ID');await RudderStack.putAnonymousId('ANON_ID');await RudderStack.flush();await RudderStack.optOut(false);Use reset() when the active user signs out and you want to clear the current Rudder identity state.
Platform notes
Section titled “Platform notes”iOS and Android
Section titled “iOS and Android”- The plugin wraps the native RudderStack SDKs directly, so there is no extra bridge dependency to install.
trackLifecycleEvents,recordScreenViews,flushQueueSize,dbCountThreshold, and related Rudder config values are supported from JavaScript.
- The web implementation is a compatibility shim for development and API parity.
- It validates initialization state, but it does not send live events to RudderStack.
Current Capacitor port limits
Section titled “Current Capacitor port limits”config.factoriesfromrudder-sdk-cordovais currently ignored.- Native destination factory companion plugins are not part of this first Capacitor release.
Best practices
Section titled “Best practices”- Initialize RudderStack once during app startup and keep the
writeKeyplusdataPlaneUrlin centralized runtime config. - Call
identify()after authentication andreset()on logout to keep profile transitions consistent. - Gate
optOut()and advertising-related identifiers behind your consent flow. - Use
flush()for critical handoff points if you need to reduce delivery latency before app backgrounding.
For the full API surface and native packaging details, see the plugin repository.