Academy / Ship the SDK Lesson 8
How to track events in React Native Track events, identify users, manage consent and run personalization in React Native apps on iOS and Android.
Video coming The video is being filmed. The steps below are the whole lesson.
In this lesson 1 React Native: npm install @intempt-technologies/react-native, run cd ios && pod install, then const intempt = await init({ apiKey, orgId, projectId, sourceId }) before the first screen. 2 React Native: await intempt.identify('user-id', { userAttributes }) then await intempt.track('Event', { ... }). Read the reference docs for this lesson Setup checklist The 18 steps to ship the SDK, from your first line of code to an identified event in Live. Tick them off as you go; your ticks stay in this browser.
Open the setup checklist (PDF)0 of 18 ticked
1. Decide your path: browser autocapture plus track() for web pages, or a server SDK or the Track Data API for anything with no browser.2. In the console go to Integrations, add a source for your platform (Configure JavaScript, Node JS, Python, PHP, iOS, Android or React Native), name it, and copy the Installation Snippet and Source ID.3. Get an API key in prefix.secret form from Settings, API keys, and keep it out of source control.4. Browser: add the queue stub and <script async src="https://cdn.intempt.com/v1/intempt.min.js?organization=...&project=...&source=...&key=..."> to the page <head>. Test on a real domain, not localhost.5. Browser: call intempt.identify({ userId }) then intempt.track({ eventTitle, data }) with non-empty data.6. Node: npm install intempt-nodejs-sdk, then Intempt.init({ org, project, apiKey, sourceId }) once per process, with sourceId as a string.7. Node: await intempt.identify({ userId, traits }) and await intempt.track('event', { userId, properties }); call await intempt.close() at shutdown.8. Python: install the intempt package, then Intempt(org=..., project=..., api_key=..., source_id=...) with source_id as a string.9. Python: intempt.identify(user_id=..., traits=...) then intempt.track("event", user_id=..., properties=...); call intempt.close() at shutdown.10. PHP: composer require intempt/intempt-php (PHP 8.1+, ext-curl, ext-json), then new Intempt(['org' => ..., 'project' => ..., 'apiKey' => ..., 'sourceId' => ...]).11. PHP: $intempt->identify(['userId' => ..., 'traits' => ...]) then $intempt->track('event', ['userId' => ..., 'properties' => ...]).12. iOS: add https://github.com/intempt/intempt-swift.git from 0.4.0 via Swift Package Manager, or pod 'Intempt', '~> 0.4.0'; then try IntemptInstance.initialize(apiKey:orgId:projectId:sourceId:) at launch (iOS 15+).13. iOS: intempt.identify(userId:) then intempt.track(eventTitle:data:).14. Android: add implementation("com.intempt.sdk:intempt-android:<version>"), declare android.permission.INTERNET, put credentials in src/main/assets/intempt-config.json, and call Intempt.initialize(this) in Application.onCreate().15. Android: Intempt.identify("user-id") then Intempt.track("Event name").16. React Native: npm install @intempt-technologies/react-native, run cd ios && pod install, then const intempt = await init({ apiKey, orgId, projectId, sourceId }) before the first screen.17. React Native: await intempt.identify('user-id', { userAttributes }) then await intempt.track('Event', { ... }).18. Open Events, then the Live tab, and watch your event arrive. Do not skip the wait.You are done when Your custom event appears on Events, Live in the console. The event is attached to the identified user's profile, not an anonymous one. Browser only: tested on a real domain, since tracking is blocked on localhost. Server SDKs: flush or close ran so buffered events were sent before the process exited. Your tech stack and tools The core stack (everything you actually need) Highly recommended optional upgrades that level up your work Every SDK is free. Your first 100K events a month are included on every plan.