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
shopNamestringYour Shopify store identifier.
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.

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
}