Skip to content

Behavior Events

The MovableInk SDK allows you to send specific behavior events that can be later used in your Campaigns.

Setup

You'll need an API Key to enable Behavior Events for your app. If you don't already have one, please reach out to your CX Team at MovableInk with your applications bundle identifier.

Once you have an API Key, you can supply it via the start method, alongside your companies region:

MIClient.start(apiKey: "MY_API_KEY", region: .us)

If you are also using deeplinking, you may notice the start method above looks different. Your implementation would look something like this:

MIClient.start(
  apiKey: "MY_API_KEY",
  region: .us, 
  deeplinkDomains: ["mi.example.com"],
) { result in 
  ...
}

or you can add two new key/value pairs in your applications Info.plist, one for the API Key, and one for the region:

movable_ink_region must be one of following:

  • us
  • eu
<key>movable_ink_api_key</key>
  <string>YOUR_API_KEY</string>
<key>movable_ink_region</key>
  <string>eu</string>

If you don't supply a region, the SDK will default to the US region. If you are unsure which region your company was setup in on the MovableInk Platform, please reach out to your CX team at MovableInk.

Setting MIU (mi_u)

An MIU is an identifier used by your companies marketing team and email/mobile messaging provider, that when shared with MovableInk, allows to uniquely identify each of your customers when the interact with campaigns or any other MovableInk content.

Most distribution partners provide a unique user identifier as an available merge tag that distinctly identifies every recipient on your list(s). Using this merge tag allows MovableInk to provide users with a consistent experience when opening the same email multiple times and across multiple devices. Providing an MIU is required for accurate behavior and conversion tracking.

You'll need to work with your distribution partners to identify a unique user identifier. It must meet the following criteria:

You should make the following call as soon as the user is identified (usually after logging in) to set the MIU. Double check with your marketing team that the MIU you're using matches the values they are using. It's imperative that they match for accurate behavior event tracking.

MIClient.setMIU(USERS_MIU)
[MIClient setMIU:USERS_MIU];

Inherited MIUs

If a user interacts with a MovableInk Link that contains an MIU and deeplinks into your app, the SDK will use that MIU value automatically for all subsequent behavior events if you don't manually set an MIU.

If you manually set an MIU, events will use that instead.

Suggested MIU naming convention

We strongly recommend you use a UUID for MIUs.

If you find your ids include names, email addresses, timestamps, or are easily incremental (1, 2, 3), we suggest using a new naming method that is more secure so that your MIUs are not as easy to guess or impersonate.

Recommended NOT Recommended
42772706-c225-43ad-837e-c01e94907c3c user@example.com
d68d3dbe-86e1-43ce-bf5f-2dafd2f6af45 123456789
6ec4f1dd-0998-4ca8-8793-7511c2625a45 john-smith-123

Predefined Events

Category Viewed

Key Type Description Max
id String, required, must not be empty The ID of a category 256
title String The title of the category 512
url String The URL of the category 512

When a views a category, you can use the Category Viewed Event.

MIClient.categoryViewed(category:) takes a ProductCategory type as an argument to describe the category.

ProductCategory requires an ID, and optionally other fields.

ID must not be an empty string. Sending a proper ID is extremely important as it acts as the primary key which powers multiple use cases. This event will fail if you do not provide an ID.

MIClient.categoryViewed(
  category: .init(
    id: "sci-fi",
    title: "Sci-Fi",
    url: URL(string: "https://inkrediblebooks.com/categories/scifi")
  )
)

Product Searched

Key Type Description Max
query String, required, must not be empty The query the user used for a given search 256
url String A URL for the given query 512

When a user searches for a product, you can use the Product Searched Event.

MIClient.productSearched(properties:) takes a ProductSearchedProperties type as an argument to describe the query of the search.

ProductSearchedProperties requires a query, and optionally other fields.

MIClient.productSearched(
  properties: .init(
    query: "Hyperion"
    url: URL(string: "https://inkrediblebooks.com/categories/scifi")
  )
)

Note that this request will be debounced

Product Viewed

Key Type Description Max
id String, required, must not be empty The ID of a product 256
title String The title of the product 512
price String The price of the product in Dollars and Cents. Do not include currency or any other non-decimal digit characters.
url String The URL of the product 512
categories Array<ProductCategory> An array of categories associated with the product. A category must contain an id (String) and optionally a url (String) and/or title (String) 10 Items
meta Dictionary<String, Value> An open Dictionary of any extra data you'd like to associate to this event. The Value must be either a String, Boolean, or Numeric. Meta does not accept nested objects or arrays. 20 Items

When a user views a product in your app, you can use the Product Viewed Event.

MIClient.productViewed(properties:) takes a ProductProperties type as an argument to describe the product.

ProductProperties requires an ID, and optionally other fields.

ID must not be an empty string. Sending a proper ID is extremely important as it acts as the primary key which powers multiple use cases. This event will fail if you do not provide an ID.

MIClient.productViewed(
  properties: .init(
    id: "1",
    title: "Hyperion",
    price: "15.99",
    url: URL(string: "https://inkrediblebooks.com/hyperion-dan-simmons")!,
    categories: [
      ProductCategory(id: "Sci-Fi", url: URL(string: "https://inkrediblebooks.com/categories/scifi")!),
      ProductCategory(id: "Fiction", url: URL(string: "https://inkrediblebooks.com/categories/fiction")!)
    ],
    meta: [
      "pages": 496
    ]
  )
)

Note that the price is in dollars and cents. Using a String is recommended. There are overloads for numerical types such as Double or Int which will attempt to convert to a String for you.

For example, if you supply an Int, such as 15, it will be inferred as 15.00.

Product Added

Key Type Description Max
id String, required, must not be empty The ID of a product 256
title String The title of the product 512
price String The price of the product in Dollars and Cents. Do not include currency or any other non-decimal digit characters.
url String The URL of the product 512
categories Array<ProductCategory> An array of categories associated with the product. A category must contain an id (String) and optionally a url (String) and/or title (String) 10 Items
meta Dictionary<String, Value> An open Dictionary of any extra data you'd like to associate to this event. The Value must be either a String, Boolean, or Numeric. Meta does not accept nested objects or arrays. 20 Items

When a user adds a product to the cart in your app, you can use the Product Added Event.

MIClient.productAdded(properties:) takes a ProductProperties type as an argument to describe the product.

ProductProperties requires an ID, and optionally other fields.

ID must not be an empty string. Sending a proper ID is extremely important as it acts as the primary key which powers multiple use cases. This event will fail if you do not provide an ID.

MIClient.productAdded(
  properties: .init(
    id: "1",
    title: "Hyperion",
    price: "15.99",
    url: URL(string: "https://inkrediblebooks.com/hyperion-dan-simmons")!,
    categories: [
      ProductCategory(id: "Sci-Fi", url: URL(string: "https://inkrediblebooks.com/categories/scifi")!),
      ProductCategory(id: "Fiction", url: URL(string: "https://inkrediblebooks.com/categories/fiction")!)
    ],
    meta: [
      "pages": 496
    ]
  )
)

Note that the price is in dollars and cents. Using a String is recommended. There are overloads for numerical types such as Double or Int which will attempt to convert to a String for you.

For example, if you supply an Int, such as 15, it will be inferred as 15.00.

Product Removed

Key Type Description Max
id String, required, must not be empty The ID of a product 256
title String The title of the product 512
price String The price of the product in Dollars and Cents. Do not include currency or any other non-decimal digit characters.
url String The URL of the product 512
categories Array<ProductCategory> An array of categories associated with the product. A category must contain an id (String) and optionally a url (String) and/or title (String) 10 Items
meta Dictionary<String, Value> An open Dictionary of any extra data you'd like to associate to this event. The Value must be either a String, Boolean, or Numeric. Meta does not accept nested objects or arrays. 20 Items

When a user removes a product from the cart in your app, you can use the Product Removed Event.

MIClient.productRemoved(properties:) takes a ProductProperties type as an argument to describe the product.

ProductProperties requires an ID, and optionally other fields.

ID must not be an empty string. Sending a proper ID is extremely important as it acts as the primary key which powers multiple use cases. This event will fail if you do not provide an ID.

MIClient.productRemoved(
  properties: .init(
    id: "1",
    title: "Hyperion",
    price: "15.99",
    url: URL(string: "https://inkrediblebooks.com/hyperion-dan-simmons")!,
    categories: [
      ProductCategory(id: "Sci-Fi", url: URL(string: "https://inkrediblebooks.com/categories/scifi")!),
      ProductCategory(id: "Fiction", url: URL(string: "https://inkrediblebooks.com/categories/fiction")!)
    ],
    meta: [
      "pages": 496
    ]
  )
)

Note that the price is in dollars and cents. Using a String is recommended. There are overloads for numerical types such as Double or Int which will attempt to convert to a String for you.

For example, if you supply an Int, such as 15, it will be inferred as 15.00.

Order Completed

Key Type Description Max
id String The ID of a order 256
revenue String The total of the order in Dollars and Cents. Do not include currency or any other non-decimal digit characters.
products Array<OrderCompletedProduct> An of the products in an order. A OrderCompletedProduct must contain an id (String), and optionally a price (String), quantity (Number), title (String), and/or url (String). 100 Items

When a user checks out and completes an order, you can use the Order Completed Event.

MIClient.orderCompleted(properties:) takes a OrderCompletedProperties type as an argument to describe the order and its items.

OrderCompletedProperties requires an ID and a list of products as an OrderCompletedProduct, and optionally other fields.

ID fields must not be an empty string. Sending a proper ID is extremely important as it acts as the primary key which powers multiple use cases. This event will fail if you do not provide an ID.

MIClient.orderCompleted(
  properties: .init(
    id: "1",
    revenue: "15.99",
    products: [
      .init(
        id: "1",
        title: "Hyperion",
        price: "15.99",
        url: URL(string: "https://inkrediblebooks.com/hyperion-dan-simmons")!,
        quantity: 1
      )
    ]
  )
)

Note that the reveune and price is in dollars and cents. Using a String is recommended. There are overloads for numerical types such as Double or Int which will attempt to convert to a String for you.

For example, if you supply an Int, such as 15, it will be inferred as 15.00.

Custom Events

In addition to the pre-defined events we provide, you can log custom events tailored to your business specific requirements. This flexibility enables you to monitor and understand user interactions beyond what our pre-defined events offer.

This type of event has a custom name name, such as video_started, and optional parameters as the payload.

The name and properties of a custom event must first be defined on your companies account. Please reach out to your CX Team at MovableInk to get started with this.

MIClient.logEvent(name: "video_started", properties: ["title": "Cat Bloopers"])

Testing Behavior Events

When you're ready to test an event, you need to set the MIU to a known value. You should let your CX Team know that you're ready to start testing events and give them the MIU that you are going to use before you do so. This will allow them to verify that the events are being sent correctly.

We usually use an empty UUID for testing, such as 00000000-0000-0000-0000-000000000000.

When you send an event, you should see the event logged in the console. If the event was structured correctly, you should see a success message in the console along side the event name.