Fire the call inside your add-to-cart action handler — after the cart state is updated locally. Don't pass the SKU, price, quantity, or variant; your commerce backend has all of them.
▸Install the React Native SDK
npm install @respectlytics/react-native
# or
yarn add @respectlytics/react-native
JavaScript-only — no native modules, no auto-linking, no New Architecture migration concerns. Bundle size: ~14KB minified+gzipped. Works in any Expo project (managed or bare) without expo prebuild.
▸Initialize Respectlytics in React Native
// App.tsx (or App.js)
import { useEffect } from 'react';
import Respectlytics from '@respectlytics/react-native';
export default function App() {
useEffect(() => {
Respectlytics.configure({ appKey: '<YOUR_APP_KEY>' });
}, []);
return <YourApp />;
}
Initialize once in your top-level component. No native config; no Info.plist or AndroidManifest changes. The SDK is Hermes- and JSC-compatible.
▸Track the event in React Native
import Respectlytics from '@respectlytics/react-native';
export async function addToCart(productId, quantity = 1) {
await cartApi.add(productId, quantity);
Respectlytics.track('add_to_cart');
}
export async function removeFromCart(productId) {
await cartApi.remove(productId);
Respectlytics.track('remove_from_cart');
}
Quantity changes (going from qty=1 to qty=2 on an existing line) shouldn't fire add_to_cart again — it's a separate UX event.
✦Privacy & implementation notes
Your commerce platform (Shopify, BigCommerce, your own service) is the authoritative cart system — it has SKU, price, quantity, variant, with proper retention and access policies. Mirroring cart contents into product analytics duplicates a system of record and produces drift the moment products are renamed or repriced.
Most product decisions about add-to-cart are about rate changes — "did the new product detail page move our DE iOS add-to-cart rate?". That question doesn't require knowing what specific items got added; it requires knowing the count of add_to_cart events relative to product_detail_view.
The React Native SDK is JavaScript-only — no Objective-C/Swift bridging on iOS, no Java/Kotlin bridging on Android. Side effects: no react-native link, no auto-linking, no New Architecture migration concerns, no platform-channel exception surfaces. Trade-off: no access to platform-only metadata (which we don't want to collect anyway).
Works in Expo managed workflow without expo prebuild. No config plugin is required. EAS Build users: nothing to configure. This is the smoothest integration path on RN — most analytics SDKs require ejecting from managed.
⇋How this compares to other analytics SDKs
| Add-to-cart event | Firebase Analytics | Mixpanel | Respectlytics |
|---|---|---|---|
| SKU / variant ID | Recommended | Recommended | Out of scope |
| Price / currency / quantity | Recommended | Recommended | Rejected by API |
| Cart total at this step | Recommended | Recommended | Out of scope |
| Per-user cart abandonment recovery | Yes | Yes | Out of scope (use cart backend) |
| Add-to-cart *rate* by country / platform | Yes | Yes | Yes |
❓Frequently asked questions
How do we know what's in users' carts without storing items?
Your commerce backend already has authoritative cart state per user. Respectlytics tells you the add-to-cart rate and how it correlates with checkout completion at the session level. Per-user abandoned-cart recovery is a marketing-automation use case, handled by your cart backend's webhooks (Shopify Plus, Klaviyo, etc.).
What about category-level adds (apparel vs electronics)?
If you have a small fixed set of top-level categories (under 8), distinct event names: add_to_cart_apparel, add_to_cart_electronics. Past that, skip the breakdown — your commerce backend has the granular data.
Should we instrument every cart-line edit (quantity changes, removals)?
Removals: yes, distinct event name remove_from_cart — the rate of removals near checkout is a UX signal. Quantity changes: not usually; they don't carry much product signal at the aggregate.
What if the same user adds and removes the same item rapidly?
Both events fire — Respectlytics doesn't dedupe. The rate of remove_from_cart shortly after add_to_cart is itself a UX signal (price reveal, shipping shock, etc.). Bucketing rates over country / platform makes those patterns visible without per-user tracking.