Respectlytics Respect lytics
Menu
React Native Content shared Privacy-first

How to track content share events in React Native without personal data

Content share — "share to Messages", "share to Twitter", "copy link" — is a viral-loop signal in social and content apps. Most analytics SDKs default to logging the destination app, the shared content ID, and sometimes the recipient. Respectlytics helps developers avoid collecting personal data in the first place: in React Native, share is one named event per channel, with no payload. Below: the React Native share-sheet integration, why channel goes in the event name, and what stays out.

Fire the call inside the share-sheet completion callback when the user has actually completed the share (not when they open the sheet — abandonment is common). Encode the chosen channel into the event name.

Install the React Native SDK

bash Respectlytics
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

js Respectlytics
// 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

js Respectlytics
import Respectlytics from '@respectlytics/react-native';
import { Share } from 'react-native';

export async function shareContent(message) {
  try {
    const result = await Share.share({ message });
    if (result.action === Share.sharedAction) {
      // iOS fills in `activityType`; Android leaves it null.
      const channel = result.activityType?.split('.').pop() ?? 'other';
      Respectlytics.track(`share_${channel.toLowerCase()}`);
    } else if (result.action === Share.dismissedAction) {
      Respectlytics.track('share_cancelled');
    }
  } catch {}
}

iOS reports the chosen channel via activityType; Android does not (returns null). Fall back to share_other on Android — or fire individual platform-specific share intents for finer attribution.

Privacy & implementation notes

Putting the channel as a parameter ({ channel: 'twitter' }) is the natural first instinct and is exactly what Respectlytics's API rejects. Encode it as the event name — share_twitter — and you get the same downstream queryability without storing parameters.

Fire on share completion, not on share-sheet presentation. Share-sheet presentation is fairly common (the user is just exploring); actual completion is much rarer and is the meaningful signal. The two rates differ by 5–10× in most apps.

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

Share eventFirebase AnalyticsMixpanelRespectlytics
Share channel as parameterRecommendedRecommendedUse distinct event_name
Shared content IDRecommendedRecommendedOut of scope (use content backend)
Recipient data (when accessible)PossiblePossibleForbidden (PII)
Per-user share countYesYesOut of scope
Share rate by content / channelPer-userPer-userUse distinct event_names + content backend

Frequently asked questions

How do we know which channels are most popular?

Distinct event names per channel: share_imessage, share_email, share_twitter, share_copy_link. Aggregation gives per-channel rate. iOS's UIActivityViewController and Android's Intent chooser deliver the selected channel in the completion callback — encode it into the event name.

What about shared content metadata?

Stays in your content backend. The CMS or content database knows what was shared. Respectlytics tells you that a share happened in this session — the join to specific content is a backend concern.

Can we measure share-induced installs?

Server-side via deferred deep links and install attribution. App Store Connect / Play Console deliver the attribution; your backend correlates the shared link's tracking parameter with the resulting install. Respectlytics doesn't ingest install attribution — it's not the right system for that.

What if the share sheet completes but the user cancels?

iOS's UIActivityViewController and Android's Intent chooser both call back with a cancellation flag. Don't fire share_* on cancel — fire share_cancelled (a single event regardless of channel) if you want to track abandonment.

Related guides

Track what matters. Collect nothing you don't.

Five-field event schema, RAM-only event queue, no IDFA, no AAID, no persistent user IDs. Helps developers avoid collecting personal data in the first place.