react-native-marfeel-tracker
v0.1.1
Published
React native marfeel tracker
Maintainers
Readme
react-native-marfeel-tracker
React Native bindings for Marfeel CompassTracking SDK that let you record pageviews, clicks and user metadata from JavaScript while delegating the heavy lifting to the native Android and iOS SDKs. Android uses the Compass Views artifact, while iOS depends on MarfeelSDK-iOS as described in the official instrumentation guide.
Installation
# with npm
npm install react-native-marfeel-tracker
# or with yarn
yarn add react-native-marfeel-trackerAndroid: make sure your
android/settings.gradle(orsettings.gradle.kts) lists the Marfeel repositories so Gradle can resolve the Compass artifacts:dependencyResolutionManagement { repositories { google() mavenCentral() maven { url = uri("https://www.jitpack.io") } maven { url = uri("https://repositories.mrf.io/nexus/repository/mvn-marfeel-public/") } } }iOS: run
cd ios && pod installso Cocoapods can fetchMarfeelSDK-iOS.
Quick start
import MarfeelTracker from 'react-native-marfeel-tracker';
MarfeelTracker.initialize('ACCOUNT_ID_FROM_MARFEEL');
MarfeelTracker.trackPage('https://example.com/home');
MarfeelTracker.setSiteUserId('user-123');
MarfeelTracker.setUserType('logged');
// Track UI interactions as conversions/clicks
MarfeelTracker.trackClick('cta.primary'); // Same as trackConversion('click:cta.primary')Using the published package
Install the package with
npm install react-native-marfeel-tracker(oryarn addas shown above).Run the native autolinking steps:
- Android: no extra configuration is needed beyond a regular Gradle sync.
- iOS:
cd ios && pod install.
Import the module from JavaScript/TypeScript:
import MarfeelTracker from 'react-native-marfeel-tracker'; MarfeelTracker.initialize('YOUR_ACCOUNT_ID'); MarfeelTracker.trackPage('https://example.com');Whenever you publish a new version to npm, make sure the
lib/artifacts are up to date (yarn clean && yarn prepare) before runningnpm publish --access public.
API
initialize(accountId: string, options?: { pageTechnology?: number })trackPage(url: string, options?: { recirculationSource?: string })trackScreen(screen: string, options?: { recirculationSource?: string })stopTracking()setLandingPage(landingPage: string)setSiteUserId(userId: string)getUserId(): stringsetUserType('anonymous' | 'logged' | 'paid' | { customId: number })setConsent(consent: boolean)trackConversion(conversion: string)andtrackClick(target: string)setPageVar / setSessionVar / setUserVaraddUserSegment,setUserSegments,removeUserSegment,clearUserSegmentssetPageMetric(name: string, value: number)
Under the hood these functions call the corresponding CompassTracking APIs documented by Marfeel, so the same behaviors and constraints apply (e.g. metrics accept integers only, custom user types require IDs above 100, and account IDs must be numeric) [^docs].
[^docs]: References: Native Android SDK instrumentation and Native iOS SDK instrumentation.
Contributing
License
MIT
Made with create-react-native-library
