Mobile SDK Methods

The React Native API is the canonical surface shown here. Native Android and iOS expose the same events with platform-typed payloads.

All tracking methods are fire-and-forget: they do not return promises and do not throw. A malformed payload or a missing native module produces a console warning, never an exception. getConsentStatus() is the only async method.

Lifecycle

init(shopName, msCountry, curr)

Required once at app startup.

ParameterTypeDescription
shopNamestringThe unique identifier for the shop (e.g. example.myshopify.com). This is the shop-id value in your Triple Whale app URL (for example ?shop-id=example.myshopify.com).
msCountrystringCountry code for attribution.
currstringCurrency code.

Tracking

pageView(url)

Screen view.

ParameterTypeDescription
urlstringThe screen path or URL.

pageViewWithProduct(url, productId, productName, productPrice)

Screen view with product context.

ParameterTypeDescription
urlstringThe screen path or URL.
productIdstringThe product identifier.
productNamestringThe product name.
productPricestringThe product price, e.g. "29.99".

addToCart(productId, variant, price, quantity)

Item added to cart.

ParameterTypeDescription
productIdstringThe product identifier.
variantstringThe variant identifier. Pass an empty string if no variant.
pricenumberPer-unit price.
quantitynumberNumber of units added.

contact(email, phone?)

Capture user contact info.

ParameterTypeDescription
emailstringThe user's email address.
phonestring (optional)The user's phone number.

custom(name, properties?)

Your own named event.

ParameterTypeDescription
namestringThe event name. event_name is reserved.
propertiesobject (optional)Up to 10 properties. Keys max 40 characters; values are stringified and capped at 100 characters.

Breaching any limit drops the whole event rather than sending a partial one. Call pageView at least once first; custom events carry the current page-view session ID.

Identity

identify(userId, userData?)

Associate the session with your own user ID.

ParameterTypeDescription
userIdstringYour identifier for the user.
userDataobject (optional){ email?, phone?, firstName?, lastName? }. Each field max 255 characters.

Call it after login or signup; once per session is enough. Call pageView at least once first — identify events carry the current page-view session ID, and without one the event can't be tied to the session. The ID is persisted (Android SharedPreferences, iOS NSUserDefaults) and attached to later identify, page-view, and custom events. An over-long field drops the whole call rather than sending a truncated value.

reset()

Forget the ID set by identify, e.g. on logout.

Sends no event. Later events fall back to the anonymous ID; the anonymous ID and consent state are left untouched.

Checkout funnel

All checkout methods accept the same CheckoutOptions object:

type CheckoutOptions = {
  email: string;            // required (or phone)
  phone?: string;
  firstName?: string;
  lastName?: string;
  orderId?: string;         // required for purchase()
  token?: string;
  checkoutUrl?: string;
  lineItems: LineItem[];    // required, non-empty
  discountTotal?: number;
  discountCodes?: string[];
};

type LineItem = {
  id: string;
  quantity: number;
  variant?: string;
  price?: number;           // per-unit
};
MethodFunnel step
checkoutStarted(options)User entered checkout.
paymentSubmitted(options)Payment info submitted.
purchase(options)Order confirmed. Requires orderId.
addressSubmitted(options)Shipping address submitted.
contactSubmitted(options)Contact info submitted.
shippingSubmitted(options)Shipping method submitted.
const order = {
  email: '[email protected]',
  firstName: 'Sam',
  lastName: 'Brown',
  lineItems: [
    { id: '42', quantity: 2, variant: 'red-M', price: 29.99 },
    { id: '99', quantity: 1, price: 9.99 },
  ],
  orderId: '1001',
  token: 'abc123',
  discountTotal: 5.00,
  discountCodes: ['SUMMER5'],
};

TriplePixel.checkoutStarted(order);
TriplePixel.contactSubmitted(order);
TriplePixel.addressSubmitted(order);
TriplePixel.shippingSubmitted(order);
TriplePixel.paymentSubmitted(order);
TriplePixel.purchase(order);

Consent

setConsentGranted()

Mark consent as granted. Tracking proceeds normally.

setConsentDenied()

Mark consent as denied. Clears the persisted user ID and session state, cancels in-flight sends, and blocks every subsequent track call. Persists across app restarts.

getConsentStatus()

Returns Promise<'UNKNOWN' | 'GRANTED' | 'DENIED' | undefined>. Resolves to undefined if the native module is unreachable. Never rejects.

const status = await TriplePixel.getConsentStatus();
if (status === 'UNKNOWN') {
  // Show your consent banner
}