Skip to main content
@capgo/capacitor-rudderstack Analytics Open source

RudderStack Capacitor plugin

RudderStack analytics, identity resolution, screen tracking, and delivery controls for Capacitor

Install

bun add @capgo/capacitor-rudderstack bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-rudderstack
  • pnpm add @capgo/capacitor-rudderstack
  • yarn add @capgo/capacitor-rudderstack

Guide

How to use RudderStack in Capacitor

Test on device

Download the Capgo app, then scan the QR code.

RudderStack plugin preview QR code

Using @capgo/capacitor-rudderstack

Capacitor API that mirrors the public surface of rudder-sdk-cordova.

Install

bun add @capgo/capacitor-rudderstack
bunx cap sync

bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.

Import

import { nativePlugin } from '@capgo/capacitor-rudderstack';

API at a glance

Method Description
initialize Initializes the RudderStack client.
identify Sends an identify call for the provided user id.
group Sends a group call for the provided group id.
track Sends a track call for the provided event name.
screen Sends a screen call for the provided screen name.
alias Aliases the current user to a new identifier.
reset Resets the current RudderStack identity state.
flush Flushes queued events immediately.
putDeviceToken Sets the push token that RudderStack forwards to supported destinations.
setAdvertisingId See the source definitions for current behavior.
putAdvertisingId Sets a custom advertising id value.
setAnonymousId See the source definitions for current behavior.
putAnonymousId Sets a custom anonymous id value.
optOut Toggles RudderStack tracking opt-out.

Examples

initialize()

Initializes the RudderStack client.

import { nativePlugin } from '@capgo/capacitor-rudderstack';

await nativePlugin.initialize('write-key-123');

identify()

Sends an identify call for the provided user id.

import { nativePlugin } from '@capgo/capacitor-rudderstack';

await nativePlugin.identify('user-id-123');

group()

Sends a group call for the provided group id.

import { nativePlugin } from '@capgo/capacitor-rudderstack';

await nativePlugin.group('group-id-123');

track()

Sends a track call for the provided event name.

import { nativePlugin } from '@capgo/capacitor-rudderstack';

await nativePlugin.track('event');

screen()

Sends a screen call for the provided screen name.

import { nativePlugin } from '@capgo/capacitor-rudderstack';

await nativePlugin.screen('screen');

alias()

Aliases the current user to a new identifier.

import { nativePlugin } from '@capgo/capacitor-rudderstack';

await nativePlugin.alias('new-id-123');

The table above lists the 14 core methods. Listener and version helpers, and the full contract of each method, are documented in the GitHub repository.

Full reference

Keep going from Using @capgo/capacitor-rudderstack

If you are using Using @capgo/capacitor-rudderstack to plan dashboard and API operations, connect it with @capgo/capacitor-rudderstack for the implementation detail in @capgo/capacitor-rudderstack, Getting Started for the implementation detail in Getting Started, API Overview for the implementation detail in API Overview, Introduction for the implementation detail in Introduction, and API Keys for the implementation detail in API Keys.

FAQ

RudderStack plugin FAQ

How do I install the RudderStack plugin in a Capacitor app?

Run "bun add @capgo/capacitor-rudderstack" (or "npm install @capgo/capacitor-rudderstack"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-rudderstack" in your app code.

Does @capgo/capacitor-rudderstack work with React, Vue and Angular?

Yes. RudderStack is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-rudderstack support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-rudderstack free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-rudderstack/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses RudderStack without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship RudderStack changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo