Question

How can I get value of a custom property using REST API?

  • 24 July 2020
  • 1 reply
  • 178 views

  • New Participant
  • 1 reply

I would like to:

  1. Add custom property.
  2. Get value of that property using REST API. 

How can I do this?

 


1 reply

Badge

@vtwy 

Just to confirm you are talking about Custom Properties, not just a property that exists on a given event.

The custom property only exists in our Modeling layer, that is to say only through a UI based API request. Any raw export or lower level api request would not include said custom property.

To be clear, using custom properties in an API request is not extremely user friendly, here is a sample regex extraction query used in an Insights report for example: (Most of the structure is to replicate the UI state of the query builder so can change from query to query)

{
"bookmark": {
"icon": "line",
"sections": {
"show": [
{
"dataset": "$mixpanel",
"value": {
"name": "test",
"resourceType": "events"
},
"resourceType": "events",
"profileType": null,
"search": "",
"dataGroupId": null,
"math": "total",
"perUserAggregation": null,
"property": null
}
],
"cohorts": [],
"group": [
{
"dataset": "$mixpanel",
"customProperty": {
"composedProperties": {
"A": {
"label": "amount",
"propertyDefaultType": "string",
"resourceType": "event",
"type": "string",
"value": "amount"
}
},
"description": "",
"displayFormula": "REGEX_EXTRACT( A , \"[0-9\\\\.]*\")",
"name": "Custom breakdown 1",
"resourceType": "events",
"propertyType": "string"
},
"customPropertyId": "$temp-cke329nr000a53j6c2rfhg3zy",
"value": "Custom breakdown 1",
"resourceType": "events",
"profileType": null,
"search": "",
"dataGroupId": null,
"propertyType": "string",
"typeCast": null,
"unit": null
}
],
"filter": [],
"formula": [],
"time": [
{
"dateRangeType": "in the last",
"window": {
"unit": "day",
"value": 30
},
"unit": "day"
}
]
},
"columnWidths": {
"bar": {}
},
"displayOptions": {
"chartType": "line",
"plotStyle": "standard",
"analysis": "linear",
"value": "absolute"
},
"sorting": {
"bar": {
"sortBy": "column",
"colSortAttrs": [
{
"sortBy": "value",
"sortOrder": "desc"
},
{
"sortBy": "value",
"sortOrder": "desc"
},
{
"sortBy": "value",
"sortOrder": "desc"
}
]
},
"line": {
"sortBy": "value",
"sortOrder": "desc"
},
"table": {
"sortBy": "column",
"colSortAttrs": [
{
"sortBy": "label",
"sortOrder": "asc"
},
{
"sortBy": "label",
"sortOrder": "asc"
},
{
"sortBy": "label",
"sortOrder": "asc"
}
]
}
},
"title": ""
},
"use_query_cache": true,
"tracking_props": {
"is_main_query_for_report": true,
"query_reason": "qb_other_update",
"report_name": "insights"
}
}

Is there something specific you are looking to accomplish with the API export that couldn’t be accomplished with Raw Export and applying the transformation in a tool you are more comfortable with?

 

Thansk,

 

Emmett

Reply


Mixpanel