React Native
Installation
Native dependencies
The SDK relies on the following React Native libraries. Add them to your project:
npm install \
@react-native-async-storage/async-storage \
@react-native-community/netinfo \
@sparkfabrik/react-native-idfa-aaid \
react-native-device-info \
react-native-fs \
react-native-logs \
react-native-play-install-referrer
iOS configuration
Link the native dependencies:
cd ios && pod install
To collect the IDFA, which is optional, add the NSUserTrackingUsageDescription key to your Info.plist:
<key>NSUserTrackingUsageDescription</key>
<string>This app uses the advertising identifier to personalize content.</string>
Android configuration
react-native-play-install-referrer needs no manual configuration beyond standard autolinking.
For @sparkfabrik/react-native-idfa-aaid, your android/build.gradle must declare minSdkVersion >= 21.
Integrating the SDK
Copy the repository’s src/ folder into your project. The expected structure is:
src/eAnalytics.tssrc/models/:eaGeneric.ts,eaCart.ts,eaEstimate.ts,eaOrder.ts,eaProducts.ts,eaSearch.ts,eaMerchandising.tssrc/models/classes/:action.ts,params.ts,product.ts,siteCentricCFlag.ts,siteCentricProperty.tssrc/utils/:currencyISO.tsand the other utilities
Supported versions: React >=18.2.0 · React Native >0.72.4 · Node >=16.
Initialisation
Call EAnalytics.init once only when the app starts, before any call to track. The SDK is a singleton: a second call to init is ignored.
import EAnalytics from './src/eAnalytics';
// In the root component or the app's entry point
useEffect(() => {
EAnalytics.init("example.demo.com", false);
}, []);
The second parameter turns debug logs in the console on (true) or off (false).
Tracking subdomain: the value to pass is supplied by your Eulerian team. It looks like
example.demo.com, withouthttps://or/. The SDK rejects hosts containing.eulerian.com.
Offline and resending: if the device has no connection when
trackis called, the tag is serialised locally and sent again automatically on the nexttrackor the next app launch. The real timestamp of the interaction is kept (ereplay-time).
Android, Install Referrer: on first launch, the SDK automatically collects the Google Play install referrer and adds it to the following tags (
ea-android-referrer).
Tag types
Every model in the SDK uses an internal Builder class with a fluent API: each method returns this, and .build() creates the final instance.
const tag = new ModelClass.Builder("page/path")
.setUID("123")
.setEmail("user@example.com")
// ... other methods
.build();
EAnalytics.track(tag);
The
path, that is, the page name, is mandatory on every tag. It is never inferred automatically. Use a hierarchical convention with|as the separator, for example"home|landing","catalog|shoes|men"or"funnel|payment|confirmation". The value is up to you, but it must stay stable and readable in reporting.
Generic method
.set(key, value): available on every Builder, it lets you add any custom parameter that no dedicated method covers. Example:.set("subscription", "monthly").
Generic page · EaGeneric
Use it on every page that is not a product, cart, order or quote page, including the homepage and the intermediate funnel steps. It reports site-centric traffic, page views, visits and natural sources.
Methods:
new EaGeneric.Builder(path), page name (mandatory)setUID(uid), internal ID of the logged-in user; consolidates cross-device historysetEmail(email), the user’s email, hashed as lower-case hexadecimal SHA-256setProfile(profile), the user’s profile (e.g.visitor,buyer,looker)setPageGroup(group), page group for reportingsetLocation(lat, lon), the device’s GPS coordinatessetNewCustomer(boolean),trueif this is a new customerset(key, value), free custom parametersetAction(action), attaches an action, replacing the previous oneputAction(action), accumulates several actions on the same tagsetProperty(property), site-centric property (SiteCentricProperty)setCFlag(cflag), context flag (SiteCentricCFlag)setStandalone(), the hit does not count as a page view in Eulerian
Example:
import EaGeneric from './src/models/eaGeneric';
const props = new EaGeneric.Builder("home|landing")
.setUID("123asd")
.setEmail("test@test.com")
.setProfile("visitor")
.setPageGroup("MY-PAGEGROUP")
.set("subscription", "monthly")
.build();
EAnalytics.track(props);
Product page · EAProducts (1 product)
Reports product page views and feeds the “Acquisition & Product Performance” report. A tag is treated as a product page when it contains exactly one product.
Product methods:
new Product.Builder(ref), product reference (mandatory)setName(name), readable product name for reportingsetGroup(group), margin group (AorB)setParams(params), product categories (e.g.prdparam-category,prdparam-brand)
Params methods:
new Params.Builder(), constructoraddParam(key, value), adds a key/value pair, string or number
Example:
import EAProducts from './src/models/eaProducts';
import Product from './src/models/classes/product';
import Params from './src/models/classes/params';
const params = new Params.Builder()
.addParam("category", "clothes")
.addParam("brand", "nike")
.build();
const product = new Product.Builder("ref-product")
.setName("name-product")
.setGroup("A")
.setParams(params)
.build();
const page = new EAProducts.Builder("product|detail")
.setUID("123asd")
.setEmail("test@test.com")
.setProfile("looker")
.addProduct(product)
.build();
EAnalytics.track(page);
Category page · EAProducts (N products)
Reports the N references shown on a results or category page. A tag is treated as a category page when it contains more than one product. The class is the same, with several calls to .addProduct().
Example:
import EAProducts from './src/models/eaProducts';
import Product from './src/models/classes/product';
const product1 = new Product.Builder("ref-product1").setName("Product 1").build();
const product2 = new Product.Builder("ref-product2").setName("Product 2").build();
const product3 = new Product.Builder("ref-product3").setName("Product 3").build();
const page = new EAProducts.Builder("category|shoes")
.setUID("123asd")
.setEmail("test@test.com")
.setPageGroup("my-pagegroup")
.addProduct(product1)
.addProduct(product2)
.addProduct(product3)
.build();
EAnalytics.track(page);
Search engine page · EASearch
Reports internal search engine queries, the number of results and search parameters.
Methods:
new EASearch.Builder(path), page name (mandatory)setName(name), search engine name (mandatory)setResults(count), number of results returnedsetParams(params), search parameters, which feedisearchkeyandisearchdatasetUID(uid), internal ID of the userset(key, value), free custom parameter
Example:
import EASearch from './src/models/eaSearch';
import Params from './src/models/classes/params';
const searchParams = new Params.Builder()
.addParam("keyword", "jacket")
.addParam("price_min", "100.00")
.addParam("price_max", "400.00")
.build();
const page = new EASearch.Builder("internal_search|jacket")
.setUID("34678")
.setName("internal_search")
.setResults(150)
.setParams(searchParams)
.build();
EAnalytics.track(page);
404 error page · EaGeneric
Flag a 404 page by adding .set("error", "1") to an EaGeneric tag. It feeds the error pages report.
import EaGeneric from './src/models/eaGeneric';
const props = new EaGeneric.Builder("error|404")
.set("error", "1")
.build();
EAnalytics.track(props);
Quote page · EAEstimate
Reports quotes and the products attached to them. Quotes are deduplicated by reference: a second call carrying the same ref is ignored.
Methods:
new EAEstimate.Builder(path), page name (mandatory)setRef(ref), unique quote reference (mandatory)setAmount(amount), total amount including tax, with a point as the decimal separatorsetType(type), quote type according to your own taxonomysetCurrency(currency), currency, if it differs from the one configured in the interfaceaddProduct(product, amount, quantity), adds a product with its unit amount and quantitysetUID(uid), internal ID of the usersetEmail(email), the user’s email, hashed as lower-case hexadecimal SHA-256set(key, value), free custom parameter
Example:
import EAEstimate from './src/models/eaEstimate';
import Product from './src/models/classes/product';
import CurrencyISO from './src/utils/currencyISO';
const product = new Product.Builder("505").setName("Estimate product").build();
const page = new EAEstimate.Builder("credit|quote")
.setRef("C4536567")
.setUID("123asd")
.setEmail("test@test.com")
.setAmount(5000.00)
.setType("credit_48months")
.setCurrency(CurrencyISO.EUR)
.set("custom-param-key", "custom-value")
.addProduct(product, 5000.00, 1)
.build();
EAnalytics.track(page);
Cart page · EACart
Reports started carts and makes it possible to calculate conversion and abandonment rates. A cart session lasts a rolling 30 minutes.
Methods:
new EACart.Builder(path), page name (mandatory)setCartCumul(boolean),false: the tag’s products represent the whole cart, as a snapshot;true: products accumulate from one call to the nextaddProduct(product, amount, quantity), adds a product with its unit amount and quantitysetUID(uid), internal ID of the usersetEmail(email), the user’s email, hashed as lower-case hexadecimal SHA-256setProfile(profile), the user’s profilesetPageGroup(group), page groupset(key, value), free custom parameter
Example:
import EACart from './src/models/eaCart';
import Product from './src/models/classes/product';
import Params from './src/models/classes/params';
const params = new Params.Builder()
.addParam("category", "T-Shirt")
.addParam("brand", "Nike")
.build();
const product = new Product.Builder("product-123")
.setName("product-name")
.setParams(params)
.build();
const page = new EACart.Builder("cart")
.setUID("123asd")
.setEmail("test@test.com")
.setProfile("shopper")
.setPageGroup("my-page-group")
.setCartCumul(false)
.addProduct(product, 50.30, 2)
.build();
EAnalytics.track(page);
Order page · EAOrder
Reports conversions and ROI. Orders are deduplicated by reference. Place this tag as early as possible in the payment funnel, so you do not lose it if the user never comes back to the app after the payment platform.
Methods:
new EAOrder.Builder(path), page name (mandatory)setRef(ref), unique order reference (mandatory)setAmount(amount), total amount including tax, excluding shipping (mandatory)setPayment(payment), payment method used (e.g.credit card,paypal)setType(type), sale type according to your own taxonomysetCurrency(currency), currency, if it differs from the one configured in the interfacesetNewCustomer(boolean),true: new buyer;false: known customersetEstimateRef(estimateRef), reference of the quote linked to this orderaddProduct(product, amount, quantity), adds a product with its unit amount and quantitysetUID(uid), internal ID of the usersetEmail(email), the user’s email, hashed as lower-case hexadecimal SHA-256setProfile(profile), the user’s profileset(key, value), free custom parameter
Example:
import EAOrder from './src/models/eaOrder';
import Product from './src/models/classes/product';
import Params from './src/models/classes/params';
import CurrencyISO from './src/utils/currencyISO';
const params = new Params.Builder()
.addParam("category", "T-Shirt")
.addParam("brand", "Nike")
.build();
const product = new Product.Builder("product-123")
.setName("product-name")
.setParams(params)
.build();
const page = new EAOrder.Builder("funnel|confirmation")
.setRef("F654335671")
.setUID("123asd")
.setEmail("test@test.com")
.setProfile("buyer")
.setNewCustomer(true)
.setAmount(50.30)
.setType("online")
.setPayment("credit card")
.setCurrency(CurrencyISO.EUR)
.set("custom-param-key", "custom-value")
.addProduct(product, 25.15, 2)
.build();
EAnalytics.track(page);
Merchandising tracking · EATpView / EATpClick
Reports impressions and clicks on merchandising blocks: recommendation lists, banners and so on. These two tags go out as GET to /tpview/ and /tpclick/, where the others go out as POST, and they benefit from the same offline resending mechanism.
EATpView methods, for the impression:
new EATpView.Builder(path), reference page (mandatory)setSiteName(name), name of the merchant sitesetCampaign(campaign), campaign namesetPlacement(placement), position of the block on the pageaddProduct(ref, position?), product reference and its position in the block, to repeat for each product shownsetUrl(url), context URLsetPublisher(publisher), publisher, optionalsetMedia(media), media type, optionalsetCategory(category), block category, optional
EATpClick methods, for the click:
new EATpClick.Builder(path), reference page (mandatory)setSiteName(name), name of the merchant sitesetCampaign(campaign), campaign namesetPlacement(placement), position of the block on the pagesetProduct(ref, position, totalProducts?), reference and position of the clicked product (mandatory), with the total number of products in the block as an optional third parametersetUrl(url), context URLsetPublisher(publisher), publisher, optionalsetMedia(media), media type, optionalsetCategory(category), block category, optional
Example:
import { EATpView, EATpClick } from './src/models/eaMerchandising';
// Impression of a merchandising block
const view = new EATpView.Builder("homepage")
.setSiteName("my-site")
.setCampaign("summer_sale")
.setPlacement("banner_top")
.addProduct("PROD_001", 0)
.addProduct("PROD_002", 1)
.setUrl("https://www.example.com")
.build();
EAnalytics.track(view);
// Click on a product in that block
const click = new EATpClick.Builder("homepage")
.setSiteName("my-site")
.setCampaign("summer_sale")
.setPlacement("banner_top")
.setProduct("PROD_001", 0)
.setUrl("https://www.example.com")
.build();
EAnalytics.track(click);
Actions · Action
Actions let you track interactions outside a standard page view: sign-up funnels, surveys, moving between sections. An action is attached to any tag with setAction(), which replaces the previous action, or putAction(), which accumulates several on the same tag.
To send an action with no associated page view, call setStandalone() on the tag: the hit will not count as a page view in Eulerian.
Methods:
new Action.Builder(), constructorsetName(name), action name (mandatory)setMode(mode), direction of the action:"in"on entry,"out"on exit, or"neat"setLabel(label), action labelsetReference(ref), reference identifying the action in your systemssetParams(params), extra key/value parameters
Action attached to a page view:
import EaGeneric from './src/models/eaGeneric';
import Action from './src/models/classes/action';
const action1 = new Action.Builder()
.setName("subscription-step1")
.setMode("in")
.setLabel("premium-offer")
.build();
const action2 = new Action.Builder()
.setName("subscription-step1")
.setMode("out")
.setLabel("abandoned")
.build();
const props = new EaGeneric.Builder("subscription|step1")
.setUID("123asd")
.putAction(action1)
.putAction(action2)
.build();
EAnalytics.track(props);
Standalone action, with no page view:
The
pathbecomes optional withsetStandalone(): the Builder acceptsnew EaGeneric.Builder()with no argument.
import EaGeneric from './src/models/eaGeneric';
import Action from './src/models/classes/action';
import Params from './src/models/classes/params';
const action = new Action.Builder()
.setName("cta-click")
.setMode("in")
.setLabel("hero-banner")
.setParams(new Params.Builder()
.addParam("origin", "martinique")
.build())
.build();
const props = new EaGeneric.Builder() // path omitted in standalone mode
.setStandalone() // does not count as a page view
.setUID("123asd")
.putAction(action)
.build();
EAnalytics.track(props);
Site-centric property · SiteCentricProperty
Attaches site-centric product properties to any tag. The API is the same as SiteCentricCFlag’s, but it feeds the property field instead of cflag.
Methods:
new SiteCentricProperty.Builder(), constructorset(key, ...values), defines a property dimension with one or more values
Example:
import EaGeneric from './src/models/eaGeneric';
import SiteCentricProperty from './src/models/classes/siteCentricProperty';
const property = new SiteCentricProperty.Builder()
.set("universe", "fish", "meat")
.set("type", "fresh")
.build();
const props = new EaGeneric.Builder("home|landing")
.setUID("123asd")
.setProperty(property)
.build();
EAnalytics.track(props);
Context Flag (CFLAG) · SiteCentricCFlag
Attaches one or more context flags to any tag, to enrich your reports with contextual dimensions. Each flag accepts several values.
Methods:
new SiteCentricCFlag.Builder(), constructorset(key, ...values), defines a contextual dimension with one or more values
Example:
import EaGeneric from './src/models/eaGeneric';
import SiteCentricCFlag from './src/models/classes/siteCentricCFlag';
const cflag = new SiteCentricCFlag.Builder()
.set("category_1", "rolandgarros", "wimbledon")
.set("category_2", "tennis")
.set("category_3", "usopen")
.build();
const props = new EaGeneric.Builder("home|landing")
.setUID("123asd")
.setEmail("email@test.com")
.setCFlag(cflag)
.build();
EAnalytics.track(props);
WebView tracking
For hybrid apps that open a WebView, pass the SDK’s internal identifier in the opening URL so that tracking carries on between the native app and the web session. Also add the edev parameter, which flags the traffic as native.
The ea-euidl-bypass parameter must carry the persistent device identifier, the one the SDK includes in every hit, not the advertising identifier. The React Native SDK has no dedicated getEuidl() method: read the value directly from react-native-device-info.
- Android, Android ID (
ea-android-id, oreuidlin the SDK):DeviceInfo.getAndroidId() - iOS, IDFV (
ea-ios-idfvin the SDK):DeviceInfo.getUniqueId()
EAnalytics.getAdInfoId()returns the advertising identifier (IDFA or GAID). It is a different identifier, and it must not be used forea-euidl-bypass.
import { Platform } from 'react-native';
import DeviceInfo from 'react-native-device-info';
const euidl = Platform.OS === 'android'
? await DeviceInfo.getAndroidId()
: await DeviceInfo.getUniqueId();
// Build the URL with the required parameters
const baseUrl = "https://www.example.com/landing";
const edev = Platform.OS === 'android' ? "AppNativeAndroidphone" : "AppNativeIOSphone";
const webViewUrl = `${baseUrl}?ea-euidl-bypass=${encodeURIComponent(euidl)}&edev=${edev}`;
// Load it in the WebView
<WebView source={{ uri: webViewUrl }} />
Accepted values for edev:
| Value | Device |
|---|---|
AppNativeIOSphone | iPhone |
AppNativeIOStablet | iPad |
AppNativeAndroidphone | Android phone |
AppNativeAndroidtablet | Android tablet |
ea-euidl-bypassmust be present on every URL change in the WebView, otherwise the link between app and web browsing is lost.
App metrics
Downloads and updates are tracked with three parameters, present in the first tag sent at launch.
| Parameter | Value | Description |
|---|---|---|
ea-appname | App name | App identifier (must never change), collected automatically by the SDK |
ea-appversion | Version string | Current version, collected automatically by the SDK |
ea-appinstalled | 1 | To pass manually if the app existed before the Eulerian integration |
The first two are collected automatically on every hit through react-native-device-info. Nothing is needed on your side, except passing ea-appinstalled during a migration.
The logic the system applies:
- the Download metric is incremented when
ea-appnameis seen for the first time for this user, withoutea-appinstalled; - the Update metric is incremented when
ea-appnameis unchanged butea-appversioncarries a new value compared with the last launch.
Migration, for an app that existed before Eulerian:
import EaGeneric from './src/models/eaGeneric';
const props = new EaGeneric.Builder("home|landing")
.set("ea-appinstalled", "1")
.build();
EAnalytics.track(props);
Consent (GDPR)
The two modes below are mutually exclusive. Choose one, and never use both in the same app.
Mode 1 · TCF v2 (gdpr_consent)
Pass the TCString generated by your CMP once per visitor, at the moment the user opts in or out.
import EaGeneric from './src/models/eaGeneric';
const props = new EaGeneric.Builder("universe|section|page")
.setUID("5434742")
.set("subscription", "monthly")
.set("gdpr_consent", "EADURF214345") // your TCString
.build();
EAnalytics.track(props);
Mode 2 · Categories (pmcat)
Pass the Eulerian identifiers of the refused categories, separated by -. Send - on its own if the user accepts everything.
import EaGeneric from './src/models/eaGeneric';
const props = new EaGeneric.Builder("universe|section|page")
.setUID("5434742")
.set("subscription", "monthly")
.set("pmcat", "1-10") // IDs of the refused categories
.build();
EAnalytics.track(props);
Example category mapping:
| Category | Eulerian ID |
|---|---|
| analytics | 1 |
| advertising | 10 |
| functional | 19 |
A user who refuses analytics and advertising therefore gives pmcat = 1-10.
Summary:
| TCF v2 mode | Categories mode | |
|---|---|---|
| Parameter | gdpr_consent | pmcat |
| When | at opt-in or opt-out | at opt-in or opt-out |
| Content | the TCString | the refused IDs, or - |
| Compatible CMP | TCF v2 CMP | Custom CMP, outside TCF |
Platform notes
Android TV: PersistentIdentity.getAdvertisingId() is not supported on Android TV and does not return the device’s advertising identifier, because of a limitation of the React Native platform.
iOS, IDFA: the SDK collects the IDFA automatically if the user has given consent through ATTrackingManager. No extra configuration is needed on the SDK side, beyond declaring NSUserTrackingUsageDescription in the Info.plist.
Android, advertising identifier: the SDK collects the GAID automatically through @sparkfabrik/react-native-idfa-aaid. If the user has turned on “Opt out of Ads Personalisation”, the LAT flag (ea-android-islat) is true.