Skip to content

Log events ​

WARNING

Default events (such as those automatically tracked on the web) are not supported in the mobile SDK. You must log events explicitly using the log* functions below.

Payload and response (all functions) ​

Every log* function sends a POST request to https://${tag}/mark with a JSON body. The payload always includes these envelope fields (added by the SDK):

FieldTypeDescription
x-cf-ipstringClient IP (from SDK)
x-cf-locstringClient location
muidstringAnonymous or identified user ID
emailstringSet if user was identified
phonestringSet if user was identified
sessionIdstringCurrent session ID
event_sourcestringAlways "mobile"
eventstringEvent name (see each function below)
…anyEvent-specific parameters
  • Response: All log* functions return Promise<void>. The HTTP response from the MarkTag server is not returned to the caller.
  • setUser: Does not send a request. It only updates user data (email/phone) in local storage; subsequent events will include that data in the payload.

Below, each function lists the payload fields (event-specific) and response in detail.


Prerequisites ​

Schema definition for MarkTagEventItem:

KeyTypeRequiredDescription
idstring✅Unique id of product
namestring❌Product Name eg. "Shirt"
categorystring❌Product Category eg. "Apparel" or "Apparel, Men's Clothing"
variantsarray❌Array of variant objects. The array itself is optional, but when provided, each object requires: attributes (object of key-value string pairs, e.g. { size: "M", color: "red" }), price (object with original (number, required), discounted (number, optional), currency (string, required)), and isAvailable (boolean).
quantitynumber❌Quantity of this product added to cart or purchased eg. 5
pricenumber❌Original price of the product before any discount eg. 7.59
descriptionstring❌Description of the Product
couponstring❌Any coupon used through checkout
discountnumber❌⚠️ Deprecated soon. Use discounted instead. Any monetary discount added to the product
discountednumber❌The discounted price of the product (final price after discount)
image_urlstring❌URL of the product image
urlstring❌URL of the product page. If not provided, the current page URL will be used. Recommended if your URL contains tracking parameters

Log Custom Event ​

javascript
await MarkTag.logEvent({
  event: "CustomEvent", // Required
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event (required) + any custom keys (all merged into the payload).
Response: Promise<void>

Log View Item ​

javascript
await MarkTag.logViewItem({
  currency: "USD",
  value: 119.99,
  type: "product",
  items: [
    // MarkTagEventItem[]
    {
      id: "edea4360-5752-4b74-a8bf-0162fc809f06",
      name: "Keychron K2 Pro",
      description: "Mechanical Keyboard",
      variants: [
        {
          attributes: { type: "VA", color: "Black" },
          price: { original: 119.99, discounted: 109.99, currency: "USD" },
          isAvailable: true
        }
      ],
      coupon: "10_OFF",
      discount: 9.99,
      discounted: 109.99,
      price: 119.99,
      quantity: 1,
      category: "keyboard",
    },
  ],
});

Payload: event: "ViewItem", currency, value, content_type (from type), products (from items).
Response: Promise<void>

Log View Content ​

Log view content takes in any parameters you provide.

javascript
await MarkTag.logViewContent({
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "ViewContent" + any keys you pass (all merged).
Response: Promise<void>

Log Page View ​

javascript
await MarkTag.logPageView("/dashboard");

Payload: event: "PageView", pageUrl (the string you pass).
Response: Promise<void>

Log View Cart ​

javascript
await MarkTag.logViewCart({
  currency: "USD",
  value: 119.99,
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
  items: [
    {
      id: "edea4360-5752-4b74-a8bf-0162fc809f06",
      name: "Keychron K2 Pro",
      description: "Mechanical Keyboard",
      variants: [
        {
          attributes: { type: "VA", color: "Black" },
          price: { original: 119.99, discounted: 109.99, currency: "USD" },
          isAvailable: true
        }
      ],
      coupon: "10_OFF",
      discount: 9.99,
      discounted: 109.99,
      price: 119.99,
      quantity: 1,
      category: "keyboard",
    },
  ],
});

Payload: event: "ViewCart", currency, value, products (from items) + any custom parameters.
Response: Promise<void>

Log Begin Tutorial ​

javascript
await MarkTag.logBeginTutorial({
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "BeginTutorial" + any keys you pass.
Response: Promise<void>

Log Complete Tutorial ​

javascript
await MarkTag.logCompleteTutorial({
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "CompleteTutorial" + any keys you pass.
Response: Promise<void>

Log Complete Registration ​

javascript
await MarkTag.logCompleteRegistration({
  method: "email", // Optional
  customParameter1: "value", // Custom parameters
});

Payload: event: "CompleteRegistration" + any keys you pass.
Response: Promise<void>

Log Contact ​

javascript
await MarkTag.logContact({
  email: "user@email.com", // Optional
  phone: "xxxxxxxxxxx", // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "Contact" + any keys you pass.
Response: Promise<void>

Log Find Location ​

javascript
await MarkTag.logFindLocation({
  location: "Dhaka", // Optional
  lat: 23.8103, // Optional
  long: 90.4125, // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "FindLocation" + any keys you pass.
Response: Promise<void>

Log Add Payment Info ​

javascript
await MarkTag.logAddPaymentInfo({
  paymentType: "credit_card", // Optional
  currency: "USD", // Optional
  value: 120, // Optional
  items: MarkTagEventItem[], // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "AddPaymentInfo", payment_type (from paymentType), value, currency, products (from items) + any custom parameters.
Response: Promise<void>

Log Add Shipping Info ​

javascript
await MarkTag.logAddShippingInfo({
  shippingTier: "standard", // Optional
  currency: "USD", // Optional
  value: 120, // Optional
  items: MarkTagEventItem[], // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "AddShippingInfo", shipping_tier (from shippingTier), value, currency, products (from items) + any custom parameters.
Response: Promise<void>

Log Add to Wishlist ​

javascript
await MarkTag.logAddToWishlist({
  currency: "USD",
  value: 120,
  products: MarkTagEventItem[], // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "AddToWishlist", currency, value, products + any custom parameters.
Response: Promise<void>

Log Begin Checkout ​

javascript
await MarkTag.logBeginCheckout({
  currency: "USD",
  value: 120,
  products: MarkTagEventItem[], // Optional
  shippingCost: 10, // Optional
  tax: 5, // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "BeginCheckout", currency, value, products, shipping_cost (from shippingCost), tax + any custom parameters.
Response: Promise<void>

Log Add To Cart ​

javascript
await MarkTag.logAddToCart({
  currency: "USD",
  value: 120,
  items: MarkTagEventItem[], // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "AddToCart", currency, value, products (from items) + any custom parameters.
Response: Promise<void>

Log Customize Product ​

javascript
await MarkTag.logCustomizeProduct({
  currency: "USD", // Optional
  value: 120, // Optional
  items: MarkTagEventItem[], // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "CustomizeProduct", currency, value, products (from items) + any custom parameters.
Response: Promise<void>

Log Initiate Checkout ​

javascript
await MarkTag.logInitiateCheckout({
  currency: "USD",
  value: 120,
  items: MarkTagEventItem[], // Optional
  shippingCost: 10, // Optional
  tax: 5, // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "InitiateCheckout", currency, value, products (from items), shipping_cost (from shippingCost), tax + any custom parameters.
Response: Promise<void>

Log Donate ​

javascript
await MarkTag.logDonate({
  currency: "USD", // Optional
  value: 120, // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "Donate", currency, value + any custom parameters.
Response: Promise<void>

Log Lead ​

javascript
await MarkTag.logLead({
  currency: "USD", // Optional
  value: 120, // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "Lead", currency, value + any custom parameters.
Response: Promise<void>

Log Login ​

javascript
await MarkTag.logLogin({
  method: "email", // Optional
  email: "user@email.com", // Optional
  phone: "xxxxxxxxxxx", // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "Login", login_method (from method) + any custom parameters. Also updates local user (email/phone) via setUser so future events include them.
Response: Promise<void>

Log Signup ​

javascript
await MarkTag.logSignup({
  method: "email", // Optional
  email: "user@email.com", // Optional
  phone: "xxxxxxxxxxx", // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "SignUp", signup_method (from method) + any custom parameters. Also updates local user (email/phone) via setUser.
Response: Promise<void>

Log Purchase ​

javascript
await MarkTag.logPurchase({
  currency: "USD", // Optional
  value: 120,
  transactionId: "1234567890", // Optional
  tax: 5.34, // Optional
  coupon: "FLASH_SALE", // Optional
  items: MarkTagEventItem[],
});

Payload: event: "Purchase", value, products (from items), tax, shipping_cost (from shippingCost), transaction_id (from transactionId), currency + any custom parameters.
Response: Promise<void>

Log Refund ​

javascript
await MarkTag.logRefund({
  currency: "USD", // Optional
  value: 120, // Optional
  transactionId: "1234567890", // Optional
  items: MarkTagEventItem[],
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "Refund", value, products (from items), currency, transaction_id (from transactionId) + any custom parameters.
Response: Promise<void>

Log Remove From Cart ​

javascript
await MarkTag.logRemoveFromCart({
  currency: "USD",
  value: 120,
  items: MarkTagEventItem[], // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "RemoveFromCart", currency, value, products (from items) + any custom parameters.
Response: Promise<void>

Log Schedule ​

javascript
await MarkTag.logSchedule({
  date: "2022-12-31", // Optional
  time: "12:00:00", // Optional
  timezone: "Asia/Dhaka", // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "Schedule" + any keys you pass.
Response: Promise<void>

javascript
await MarkTag.logSearch({
  searchTerm: "keyboard", // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "Search", search_term (from searchTerm) + any custom parameters.
Response: Promise<void>

Log Share ​

javascript
await MarkTag.logShare({
  itemId: "1234567890", // Optional
  method: "facebook", // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "Share", item_id (from itemId), share_method (from method) + any custom parameters.
Response: Promise<void>

Log Start Trial ​

javascript
await MarkTag.logStartTrial({
  currency: "USD",
  value: 120,
  predictedLifetimeValue: 1000, // Optional
  products: MarkTagEventItem[], // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "StartTrial", currency, value, predicted_ltv (from predictedLifetimeValue), products + any custom parameters.
Response: Promise<void>

Log Submit Application ​

javascript
await MarkTag.logSubmitApplication({
  applicationId: "66b38854-7069-49fa-87d3-1c1a0754f496", // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "SubmitApplication", application_id (from applicationId) + any custom parameters.
Response: Promise<void>

Log Subscribe ​

javascript
await MarkTag.logSubscribe({
  currency: "USD",
  value: 120,
  predictedLifetimeValue: 1000, // Optional
  products: MarkTagEventItem[], // Optional
  customParameter1: "value", // Custom parameters
  customParameter2: "value", // Custom parameters
});

Payload: event: "Subscribe", currency, value, predicted_ltv (from predictedLifetimeValue), products + any custom parameters.
Response: Promise<void>