Is there a way to parse json array property in mixpanel ?

  • 28 January 2021
  • 5 replies

  • New Participant
  • 4 replies

I'm using segment to pass events for mixpanel, some of the standard property from segment is in json array format.

it can be simple json format like below :

    "campaign": {
"source": "Network/FB/AdWords/MoPub/Source",
"name": "Campaign Name",
"content": "Organic Content Title",
"ad_creative": "Red Hello World Ad",
"ad_group": "Red Ones"

or can be in a json array like below :

  products: [
product_id: '507f1f77bcf86cd799439011',
sku: '45790-32',
name: 'Monopoly: 3rd Edition',
price: 19,
position: 1,
category: 'Games',
url: '',
image_url: ''
product_id: '505bd76785ebb509fc183733',
sku: '46493-32',
name: 'Uno Card Game',
price: 3,
position: 2,
category: 'Games'


Some of the property inside this json array format is important and we want to have ability to use it in mixpanel report.

We can utilize this property in filter, as filter can parse the subproperty inside the json property, thus we can do filter by the subproperty

But when we want to use it as breakdown, it is auto casted as string, and there is no way to select the subproperty instead


Is there any thing that I miss or is there workaround for this ? thanks


Best answer by Muffaddal Qutbuddin 31 January 2021, 11:22

View original

5 replies

Userlevel 4
Badge +2

@irul you will have to parse the product json in the code and send it along as event property to mixpanel via segment. That json is only for GA and not for Mixpanel. 

so basically, you transform the json into object and send to mixpanel via segment’s analytics.track call and pass the transformed object to that call.

here is how the transformed object will look like:

products = {
  product_ids : ['507f1f77bcf86cd799439011','505bd76785ebb509fc183733'],
  sku_ids: [],
  product_names:[ '45790-32','46493-32'],

order in the array corresponds to the order in actual product json.


same goes for traffic source, you will have to capture it via code and pass as event property.

@Muffaddal Qutbuddin So we need to add separated payload dedicated for mixpanel right?

Userlevel 4
Badge +2

@Muffaddal Qutbuddin So we need to add separated payload dedicated for mixpanel right?

yes correct,

Userlevel 4
Badge +4

Hi @irul and @Muffaddal Qutbuddin : If you are passing in a single Object property, we will soon make it easy for you to filter/breakdown on individual sub-properties.


We’re also considering extended the support for lists of objects - do you have some examples (other than the one mentioned above from Segment) on how you’d like to model your data as lists of Objects?




Product @ Mixpanel

@moinakb great, glad to know that. As far as in our implementation we only have two kind of model I mentioned above, single object and list of objects.