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):
| Field | Type | Description |
|---|---|---|
x-cf-ip | string | Client IP (from SDK) |
x-cf-loc | string | Client location |
muid | string | Anonymous or identified user ID |
email | string | Set if user was identified |
phone | string | Set if user was identified |
sessionId | string | Current session ID |
event_source | string | Always "mobile" |
event | string | Event name (see each function below) |
| … | any | Event-specific parameters |
- Response: All
log*functions returnPromise<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:
| Key | Type | Required | Description |
|---|---|---|---|
| id | string | ✅ | Unique id of product |
| name | string | ❌ | Product Name eg. "Shirt" |
| category | string | ❌ | Product Category eg. "Apparel" or "Apparel, Men's Clothing" |
| variant | string | ❌ | Product's variant eg. "Blue" |
| quantity | number | ❌ | Quantity of this product added to cart or purchased eg. 5 |
| price | number | ❌ | Price of the Product eg. 7.59 |
| description | string | ❌ | Description of the Product |
| coupon | string | ❌ | Any coupon used through checkout |
| discount | number | ❌ | Any monetary discount added to the product |
Log Custom Event
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
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",
variant: "VA/Black",
coupon: "10_OFF",
discount: 9.99,
price: 119.99,
currency: "USD",
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.
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
await MarkTag.logPageView("/dashboard");Payload: event: "page_view", pageUrl (the string you pass).
Response: Promise<void>
Log View Cart
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",
variant: "VA/Black",
coupon: "10_OFF",
discount: 9.99,
price: 119.99,
currency: "USD",
quantity: 1,
category: "keyboard",
},
],
});Payload: event: "ViewCart", currency, value, products (from items) + any custom parameters.
Response: Promise<void>
Log Begin Tutorial
await MarkTag.logBeginTutorial({
customParameter1: "value", // Custom parameters
customParameter2: "value", // Custom parameters
});Payload: event: "BeginTutorial" + any keys you pass.
Response: Promise<void>
Log Complete Tutorial
await MarkTag.logCompleteTutorial({
customParameter1: "value", // Custom parameters
customParameter2: "value", // Custom parameters
});Payload: event: "CompleteTutorial" + any keys you pass.
Response: Promise<void>
Log Complete Registration
await MarkTag.logCompleteRegistration({
method: "email", // Optional
customParameter1: "value", // Custom parameters
});Payload: event: "CompleteRegistration" + any keys you pass.
Response: Promise<void>
Log Contact
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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>
Log Search
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
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
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
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
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>