Skip to content

Multidimensional Attribution by Peer Comparison

1. API Description

The multidimensional attribution peer-comparison API compares attribution between two peer objects within the same time range. For example:

  • Hangzhou Store vs Nanjing Store

  • East China Region vs South China Region

  • Self-operated channel vs agency channel

Specify the following:

  • Metric to compare

  • Dimensions participating in the analysis, such as channel

  • Dimension that identifies the comparison objects, such as store

  • Filters and time ranges for the current and comparison objects

The API returns:

  • Metric values for the current and comparison objects

  • Growth and growth rate

  • Overall and relative contribution rates for each dimension combination.

2. API URL

POST /anymetrics/api/v1/attribution/dim_peer_compare

3. Common Request Headers

parameter Name Type required Max Length Description
tenant-id String Yes 32 Tenant ID used to specify the workspace where the metric resides
auth-type String Yes 32 Authentication method. Supports UID, TOKEN, ACCOUNT, and APIKEY.
auth-value String Yes 32 Authentication value corresponding to auth-type.

How to Obtain Common parameters

In Aloudata CAN, select Metric Applications in the top navigation bar, then select API Integration in the left navigation menu. You can obtain tenant-id on the API Integration page. Set auth-value according to auth-type.

image.png

4. Request parameters

4.1 Body Structure

Field Name Type required Description
metric String Yes Name of the metric participating in attribution analysis. This can be a temporary metric name
metricDefinitions Map No Temporary metric definitions, such as adding filters to an original metric
dimensions Array Yes List of dimensions participating in attribution, for example ["channel"]
attribution Object Yes Attribution-analysis configuration, including comparison method, objects, and time ranges

4.2 metricDefinitions Structure (Optional)

If you use temporary metrics, such as adding a region filter to an original metric, define them through metricDefinitions:

Field Name Type Description
refMetric String Referenced original metric code
filters Array Filter expressions applied to the temporary metric

Example:

"metricDefinitions": {
  "order_count_temp1": {
    "refMetric": "order_count",
    "filters": [
      "IN([province],\"Zhejiang\",\"Jiangsu\")"
    ]
  }
}

4.3 attribution Structure (required)

Field Name Type required Description
attributionCalculateType String Yes Attribution calculation method. AVG means average; more methods may be added later
compareDimension String Yes Dimension that identifies the comparison objects, such as "store" or "province"
filters Array No Global filters applied to the full comparison scope (currentObject + compareObject)
timeConstraint String No Time filter for the full scope. Usually leave it empty and specify time ranges separately in currentObject and compareObject
currentObject Object Yes Current object configuration, including filters and time range
compareObject Object Yes Comparison object configuration, including filters and time range

currentObject and compareObject use the same structure:

Field Name Type required Description
filters Array Yes Filters for the current or comparison object, such as a store or region
timeConstraint String Yes Time-range expression for the current or comparison object

4.4 Request Example

{
    "metric": "countDistinct_product_id",
    "dimensions": [
        "brand",
        "price_band"
    ],
    "attribution": {
        "attributionCalculateType": "ALL",
        "compareDimension": "store_type",
        "timeConstraint": "DateTrunc([metric_time],\"DAY\") = DateTrunc(Cast(\"2025-07-03 00:00:00\",\"Timestamp\"),\"DAY\")",
        "currentObject": {
            "filters": [
                "IN([store_type],\"self-operated\")"
            ]
        },
        "compareObject": {
            "filters": [
                "IN([store_type],\"franchise\")"
            ]
        }
    }
}

Description:


5. Response parameters

5.1 Top-Level Structure

Field Name Type Description
tables Array List of multiple dimension combinations and attribution tables

Each element has the following structure:

Field Name Type Description
dimensions String Dimension combination corresponding to the current attribution data. An empty string indicates an overall summary
table Object Attribution result table for the current dimension combination

5.2 Fields Inside table

Field Name Type Description
Array Value list for each dimension, such as "channel": ["online", "offline"]
@currentValue Array Metric value of the current object
@compareValue Array Metric value of the comparison object
@growth Array Growth value (current value - comparison value)
@growthRate Array Growth rate ((current value - comparison value) / comparison value)
@overallContributionRate Array Overall contribution rate
@relativeContributionRate Array Relative contribution rate. This can be empty

5.3 Response Example

{
    "data": {
        "tables": [
            {
                "dimension": "brand",
                "table": {
                    "@currentValue": [
                        6,
                        8,
                        13,
                        8,
                        7,
                        7,
                        11
                    ],
                    "@compareValue": [
                        6,
                        8,
                        13,
                        8,
                        7,
                        7,
                        11
                    ],
                    "@overallContributionRate": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null
                    ],
                    "@growthRate": [
                        "0",
                        "0",
                        "0",
                        "0",
                        "0",
                        "0",
                        "0"
                    ],
                    "@growth": [
                        "0",
                        "0",
                        "0",
                        "0",
                        "0",
                        "0",
                        "0"
                    ],
                    "brand": [
                        "Lepin",
                        "Kangyi",
                        "Baiwei",
                        "Youxuan",
                        "Dianfan",
                        "Qingquan",
                        "Fresh Choice"
                    ]
                },
                "warning": null,
                "empty": false
            },
            {
                "dimension": "price_band",
                "table": {
                    "@currentValue": [
                        23,
                        6,
                        31
                    ],
                    "@compareValue": [
                        23,
                        6,
                        31
                    ],
                    "@overallContributionRate": [
                        null,
                        null,
                        null
                    ],
                    "price_band": [
                        "40-60",
                        "0-20",
                        "20-40"
                    ],
                    "@growthRate": [
                        "0",
                        "0",
                        "0"
                    ],
                    "@growth": [
                        "0",
                        "0",
                        "0"
                    ]
                },
                "warning": null,
                "empty": false
            },
            {
                "dimension": null,
                "table": {
                    "@currentValue": [
                        60
                    ],
                    "@compareValue": [
                        60
                    ],
                    "@growthRate": [
                        "0"
                    ],
                    "@growth": [
                        "0"
                    ]
                },
                "warning": null,
                "empty": false
            }
        ],
        "warning": null
    },
    "success": true,
    "code": "200",
    "errorMsg": null,
    "detailErrorMsg": null,
    "traceId": "cced9e32f6aa4b3eb03905b51054ad4d.192.17780531304030053"
}

6.Call Example

Request Example

{
    "metric": "countDistinct_product_id",
    "dimensions": [
        "brand",
        "price_band"
    ],
    "attribution": {
        "attributionCalculateType": "ALL",
        "compareDimension": "store_type",
        "timeConstraint": "DateTrunc([metric_time],\"DAY\") = DateTrunc(Cast(\"2025-07-03 00:00:00\",\"Timestamp\"),\"DAY\")",
        "currentObject": {
            "filters": [
                "IN([store_type],\"self-operated\")"
            ]
        },
        "compareObject": {
            "filters": [
                "IN([store_type],\"franchise\")"
            ]
        }
    }
}

Response Example

{
    "data": {
        "tables": [
            {
                "dimension": "brand",
                "table": {
                    "@currentValue": [
                        6,
                        8,
                        13,
                        8,
                        7,
                        7,
                        11
                    ],
                    "@compareValue": [
                        6,
                        8,
                        13,
                        8,
                        7,
                        7,
                        11
                    ],
                    "@overallContributionRate": [
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null
                    ],
                    "@growthRate": [
                        "0",
                        "0",
                        "0",
                        "0",
                        "0",
                        "0",
                        "0"
                    ],
                    "@growth": [
                        "0",
                        "0",
                        "0",
                        "0",
                        "0",
                        "0",
                        "0"
                    ],
                    "brand": [
                        "Lepin",
                        "Kangyi",
                        "Baiwei",
                        "Youxuan",
                        "Dianfan",
                        "Qingquan",
                        "Fresh Choice"
                    ]
                },
                "warning": null,
                "empty": false
            },
            {
                "dimension": "price_band",
                "table": {
                    "@currentValue": [
                        23,
                        6,
                        31
                    ],
                    "@compareValue": [
                        23,
                        6,
                        31
                    ],
                    "@overallContributionRate": [
                        null,
                        null,
                        null
                    ],
                    "price_band": [
                        "40-60",
                        "0-20",
                        "20-40"
                    ],
                    "@growthRate": [
                        "0",
                        "0",
                        "0"
                    ],
                    "@growth": [
                        "0",
                        "0",
                        "0"
                    ]
                },
                "warning": null,
                "empty": false
            },
            {
                "dimension": null,
                "table": {
                    "@currentValue": [
                        60
                    ],
                    "@compareValue": [
                        60
                    ],
                    "@growthRate": [
                        "0"
                    ],
                    "@growth": [
                        "0"
                    ]
                },
                "warning": null,
                "empty": false
            }
        ],
        "warning": null
    },
    "success": true,
    "code": "200",
    "errorMsg": null,
    "detailErrorMsg": null,
    "traceId": "cced9e32f6aa4b3eb03905b51054ad4d.192.17780531304030053"
}

6.1 Implement Drill-Down

Query Request

curl --location --request POST 'http://127.0.0.1:8083/anymetrics/api/v1/attribution/dim_peer_compare' \
--header 'auth-type: UID' \
--header 'tenant-id: tn_19487697' \
--header 'auth-value: 463663891121963008' \
--header 'Accept-Language: zh-CN' \
--header 'Content-Type: application/json' \
--data-raw '{

    "metric": "countDistinct_product_id",
    "dimensions": [
        "price_band"
    ],
    "attribution": {
        "attributionCalculateType": "ALL",
        "compareDimension": "store_type",
        "timeConstraint": "DateTrunc([metric_time],\"DAY\") = DateTrunc(Cast(\"2025-07-03 00:00:00\",\"Timestamp\"),\"DAY\")",
        "filters": [
            "IN([brand],\"Lepin\")"
        ],
        "currentObject": {
            "filters": [
                "IN([store_type],\"self-operated\")"
            ]
        },
        "compareObject": {
            "filters": [
                "IN([store_type],\"franchise\")"
            ]
        }
    }
}'

Response Example

{
    "data": {
        "tables": [
            {
                "dimension": "price_band",
                "table": {
                    "@currentValue": [
                        1,
                        3,
                        2
                    ],
                    "@compareValue": [
                        1,
                        3,
                        2
                    ],
                    "@overallContributionRate": [
                        null,
                        null,
                        null
                    ],
                    "price_band": [
                        "0-20",
                        "40-60",
                        "20-40"
                    ],
                    "@growthRate": [
                        "0",
                        "0",
                        "0"
                    ],
                    "@growth": [
                        "0",
                        "0",
                        "0"
                    ]
                },
                "warning": null,
                "empty": false
            },
            {
                "dimension": null,
                "table": {
                    "@currentValue": [
                        6
                    ],
                    "@compareValue": [
                        6
                    ],
                    "@growthRate": [
                        "0"
                    ],
                    "@growth": [
                        "0"
                    ]
                },
                "warning": null,
                "empty": false
            }
        ],
        "warning": null
    },
    "success": true,
    "code": "200",
    "errorMsg": null,
    "detailErrorMsg": null,
    "traceId": "2537fe72c3f84f51892047a537d3592a.187.17780530872390023"
}