Documentation Index

Fetch the complete documentation index at: https://docs.mapp.com/llms.txt

Use this file to discover all available pages before exploring further.

Object Oriented Tracking

Prev Next

Object-oriented tracking is the recommended manual tracking approach for the Android SDK. Use it when you want explicit control over pages, events, products, campaigns, users, or media interactions without building raw tracking parameter maps yourself.

Recommended Approach

Use object-oriented tracking for new Android SDK v5 implementations. It is the clearest way to work with the public SDK API and avoids manual parameter mapping in most cases.

This page focuses on the strongly typed event model. If you are looking for the legacy parameter-based approach, use Query Parameter Tracking (Legacy) instead.


Methods Overview

Method

Description

trackPage(page: PageViewEvent)

Tracks a page by sending a PageViewEvent object.

trackAction(action: ActionEvent)

Tracks a user event by sending an ActionEvent object.

trackMedia(media: MediaEvent)

Tracks media interactions such as play, pause, seek, or init by sending a MediaEvent object.


Pages

Use PageViewEvent when you want to send a page request explicitly. A page event can include page parameters, session parameters, user categories, e-commerce parameters, campaign parameters, and custom parameters.

private fun trackCustomPage() {
    val pageParameters = PageParameters(
        parameters = mapOf(20 to "cp20 page parameter value"),
        pageCategory = mapOf(10 to "cg10 page category value"),
        search = "search term"
    )

    val pageEvent = PageViewEvent(name = "the custom name of page")
    pageEvent.pageParameters = pageParameters

    Webtrekk.getInstance().trackPage(pageEvent)
}

Events

Use ActionEvent for custom event tracking. An action event can include event parameters, session parameters, user categories, e-commerce parameters, campaign parameters, and custom parameters.

private fun trackAction() {
    val eventParameters = EventParameters(
        customParameters = mapOf(20 to "ck20 parameter value")
    )

    val event = ActionEvent("name of the event")
    event.eventParameters = eventParameters

    Webtrekk.getInstance().trackAction(event)
}

Note: ActionEvent.eventParameters expects an EventParameters object, not a raw Map<Int, String>.


Products and Orders

Use ECommerceParameters to send product and order information. Assign the e-commerce object to a PageViewEvent or an ActionEvent.

Product and order values are defined by you. The SDK does not enforce a currency, unit, or price basis (net or gross) — send the values that match your account configuration. For the full definition of how e-commerce values are processed and analyzed, see Orders and Products.

Product properties

Set product data through ProductParameters. Assign one or more products to ECommerceParameters.products.

Property

Description

Data type

name

Product identifier. Use a SKU or article number to support catalog imports.

String

cost

Product price. For multiple quantities, send the total price. Accepts decimal values; 0 is allowed.

Number

quantity

Number of units for the product.

Number

categories

Product categories, keyed by category ID.

Map<Int, String>

productVariant

Variant or style context of the product (not the SKU-level identifier).

String

productSoldOut

Whether the product is out of stock.

Boolean

Order properties

Set order data through ECommerceParameters.

Property

Description

Data type

orderValue

Total order value. If no order value is sent, the order is not tracked.

Number

orderID

Unique order identifier. Prevents an order from being counted more than once.

String

currency

ISO currency code (for example, EUR). Used for currency conversion into your system's default currency.

String

couponValue

Value of the applied coupon.

Number

paymentMethod

Payment method used for the order.

String

shippingServiceProvider

Shipping provider used for the order.

String

shippingSpeed

Shipping speed chosen for the order.

String

shippingCost

Shipping cost for the order.

Number

markUp

Margin or markup of the order.

Number

status

E-commerce status of the interaction. See the values below.

ECommerceParameters.Status

E-commerce status values

The status property defines the context of the e-commerce interaction. It accepts the following values:

Value

Description

NONE_STATUS

No status is sent. This is the default.

VIEWED

The product was viewed on a product detail page.

ADDED_TO_BASKET

The product was added to the shopping cart.

DELETED_FROM_BASKET

The product was removed from the shopping cart.

ADDED_TO_WISHLIST

The product was added to a wishlist.

DELETED_FROM_WISHLIST

The product was removed from a wishlist.

CHECKOUT

The product moved to checkout.

PURCHASED

The product was purchased. Use this status on the order confirmation.

If you do not set status, no e-commerce status is sent (NONE_STATUS).

private fun trackPurchase() {
    val product = ProductParameters().apply {
        name = "Product1"
        categories = mapOf(1 to "ProductCat1", 2 to "ProductCat2")
        cost = 13
        quantity = 2
    }

    val ecommerceParameters = ECommerceParameters(
        customParameters = mapOf(1 to "Custom E-Commerce Parameter")
    )
    ecommerceParameters.products = listOf(product)
    ecommerceParameters.currency = "EUR"
    ecommerceParameters.orderID = "1234nb5"
    ecommerceParameters.paymentMethod = "Credit Card"
    ecommerceParameters.shippingServiceProvider = "DHL"
    ecommerceParameters.shippingSpeed = "express"
    ecommerceParameters.shippingCost = 20
    ecommerceParameters.couponValue = 10
    ecommerceParameters.orderValue = 36
    ecommerceParameters.status = ECommerceParameters.Status.PURCHASED

    val pageEvent = PageViewEvent(name = "TrackProductConfirmed")
    pageEvent.eCommerceParameters = ecommerceParameters

    Webtrekk.getInstance().trackPage(pageEvent)
}

Campaigns

Use CampaignParameters to attach campaign information to a page or action request. Campaign tracking attributes a request to a marketing campaign, such as a newsletter or an ad.

The action property defines how the campaign contact is counted. It accepts two values:

Value

Description

CampaignParameters.CampaignAction.CLICK

The user reached your app by clicking the campaign, for example a link in a newsletter or ad. This is the standard case for campaign tracking.

CampaignParameters.CampaignAction.VIEW

The campaign was displayed to the user without a click (an impression). Set this value only when you want to measure how often a campaign was shown.

If you do not set action, the campaign is tracked as a click.

private fun trackCampaign() {
    val campaignParameters = CampaignParameters("email.newsletter.nov2020.thursday")
    campaignParameters.mediaCode = "abc"
    campaignParameters.oncePerSession = true
    campaignParameters.action = CampaignParameters.CampaignAction.CLICK
    campaignParameters.customParameters = mapOf(12 to "campaign parameter value")

    val pageEvent = PageViewEvent(name = "TestCampaign")
    pageEvent.campaignParameters = campaignParameters

    Webtrekk.getInstance().trackPage(pageEvent)
}

Users

Use UserCategories to send predefined and custom user information with a page or action request.

private fun trackUserData() {
    val userCategories = UserCategories()
    userCategories.customCategories = mapOf(1 to "user category value 1")
    userCategories.birthday = UserCategories.Birthday(day = 12, month = 1, year = 1993)
    userCategories.customerId = "CustomerID"
    userCategories.gender = UserCategories.Gender.FEMALE
    userCategories.city = "Paris"
    userCategories.country = "France"

    val pageEvent = PageViewEvent(name = "the custom name of page")
    pageEvent.userCategories = userCategories

    Webtrekk.getInstance().trackPage(pageEvent)
}

Media Tracking

Use MediaEvent together with MediaParameters to track media interactions. A media event can include required media properties and optional event parameters, session parameters, e-commerce parameters, and custom parameters.

Type

Description

MediaParameters(name, action, position, duration)

Required media payload for a media request.

MediaEvent(pageName, parameters)

Wrapper object sent with trackMedia(media: MediaEvent).

private fun trackMedia() {
    val mediaParameters = MediaParameters(
        name = "TestVideo",
        action = MediaParameters.Action.INIT.code(),
        position = 12,
        duration = 120
    )
    mediaParameters.customCategories = mapOf(20 to "media category value")

    val eventParameters = EventParameters(
        customParameters = mapOf(20 to "sporthighlights")
    )

    val mediaEvent = MediaEvent(
        pageName = "en.sports.football",
        parameters = mediaParameters
    )
    mediaEvent.eventParameters = eventParameters

    Webtrekk.getInstance().trackMedia(mediaEvent)
}

For query-parameter-based tracking and the legacy overloads, see Manual Tracking and Query Parameter Tracking (Legacy).