Query Parameter Tracking (Legacy)

Prev Next

Query parameter tracking has been deprecated. Please switch to object-oriented tracking.

This page describes the legacy query-parameter tracking APIs in the Android SDK v5. They are still available for compatibility, but they are not the recommended starting point for new implementations.

Important

For new manual integrations, use Object Oriented Tracking. Use query-parameter tracking only if you already have an implementation based on TrackingParams, need a very small compatibility layer, or are maintaining older tracking logic.

When to use this page

  • You maintain an existing Android integration that already sends TrackingParams.

  • You need to send a small number of legacy page, event, or media requests without introducing the object-based event model immediately.

  • You want to understand how predefined parameter constants such as Param and MediaParam map to the legacy API surface.

When not to use this page

  • Do not start a new implementation with this approach if you can use Object Oriented Tracking.

  • Do not use trackPage(context, ...) when automatic page tracking is enabled. In the SDK, this method returns immediately when auto-tracking is active.

  • If you only need campaign deep-link tracking, prefer the dedicated campaign flow with trackUrl(...) and the page Campaign Tracking via Deep Links.

Available legacy methods

Method

When to use it

trackPage(context, customPageName, trackingParams)

Tracks the current Android screen with an optional custom page name and optional legacy parameters. Use this only when automatic tracking is disabled.

trackCustomPage(pageName, trackingParams)

Tracks a custom page name without passing the current Context. This can be used alongside automatic tracking, but it creates an additional content ID.

trackCustomEvent(eventName, trackingParams)

Tracks a legacy custom event with optional parameter values.

trackMedia(mediaName, trackingParams)
trackMedia(pageName, mediaName, trackingParams)

Tracks legacy media requests by sending media-related values inside the parameter map. For new manual implementations, prefer the object-based media event approach documented in Object Oriented Tracking.

Working with TrackingParams

TrackingParams is a map of parameter keys and values. You can use predefined constants such as Param.INTERNAL_SEARCH, Param.MEDIA_CODE, or MediaParam.MEDIA_ACTION, and you can create your own parameter keys with customParam(ParamType, number).

val Param.CONTENT_GROUP_1
    inline get() = customParam(ParamType.PAGE_CATEGORY, 1)

val Param.PAGE_PARAM_10
    inline get() = customParam(ParamType.PAGE_PARAM, 10)

val trackingParams = TrackingParams().apply {
    putAll(
        mapOf(
            Param.CONTENT_GROUP_1 to "home",
            Param.PAGE_PARAM_10 to "promo-banner",
            Param.INTERNAL_SEARCH to "running shoes"
        )
    )
}

Use names and IDs that match the configuration in Mapp Intelligence. If you are unsure which parameter family to use, start with the more structured object-based approach instead of expanding a large legacy parameter map.

Page tracking example

Use trackPage(context, ...) for manual page tracking when automatic tracking is disabled. Use trackCustomPage(...) when you want to send a custom page independently from the current Android screen.

val pageParams = TrackingParams().apply {
    putAll(
        mapOf(
            Param.MEDIA_CODE to "email.newsletter.nov2020.thursday",
            customParam(ParamType.PAGE_PARAM, 10) to "hero-banner"
        )
    )
}

// Manual page tracking for the current screen
Webtrekk.getInstance().trackPage(this, "ProductDetail", pageParams)

// Custom page tracking without using the current Activity name
Webtrekk.getInstance().trackCustomPage("Campaign Landing Page", pageParams)

Important

trackCustomPage(...) can be used alongside automatic tracking, but it creates an additional content ID. Use it deliberately to avoid distorted page reporting.

Event tracking example

val eventParams = TrackingParams().apply {
    putAll(
        mapOf(
            customParam(ParamType.EVENT_PARAM, 15) to "cta-click",
            Param.MEDIA_CODE to "spring-sale"
        )
    )
}

Webtrekk.getInstance().trackCustomEvent("Open promotion", eventParams)

Media tracking example

Legacy media tracking uses the same parameter-map approach. Supply media-related values with MediaParam keys. For robust new implementations, prefer the object-based media API.

val mediaParams = TrackingParams().apply {
    putAll(
        mapOf(
            MediaParam.MEDIA_DURATION to "300",
            MediaParam.MEDIA_POSITION to "0",
            MediaParam.MEDIA_ACTION to "init"
        )
    )
}

Webtrekk.getInstance().trackMedia("SampleVideo", mediaParams)

mediaParams[MediaParam.MEDIA_ACTION] = "play"
mediaParams[MediaParam.MEDIA_POSITION] = "30"
Webtrekk.getInstance().trackMedia("SampleVideo", mediaParams)

The SDK fills missing media duration and position values with 0, but you should send the real values whenever they are available. Start a media session with init or play. For seek handling, send the position at the start of the seek action and follow it with play or pause after the seek is complete.

Related pages