Mixpanel Community Icon

Extracting Keys from Music Metadata for Custom Property Analysis

·
·

I have an event property called Metadata filters that contains music metadata in an array of objects. For example: [{"Genre":"indie pop"},{"Year":"2023"},{"Artist": "madonna"}] I want to create a custom property from that and extract the keys, so that I can do a breakdown by how often each of the object keys (such as genre, year and artist) were used. Any idea how or if at all possible?

  • Avatar of Johannes K.
    Johannes K.
    ·
    ·

    Found a way to kinda do it via REGEX_EXTRACT, but doesn't feel like the best way to do this.

  • Avatar of Andrew S.
    Andrew S.
    ·
    ·

    You should be able to do breakdowns on arrays directly. E.g.

  • Avatar of Andrew S.
    Andrew S.
    ·
    ·

    If your property has the array icon you can pick how you want the breakdown to work

  • Avatar of Andrew S.
    Andrew S.
    ·
    ·

    And you can stack them too.

  • Avatar of Johannes K.
    Johannes K.
    ·
    ·

    That breaks it down by each value of the key. For example, if I do this by Genre , I get a break down of all genre values. But I'd like to break it down by the key. In other words, I care about the number of times each key occurred and not about the values in each key:value pair. Any idea?

  • Avatar of Andrew S.
    Andrew S.
    ·
    ·

    In this example, I am measuring the total events (occurrences) where max, min or not set is the key for the filter. Vs the values of those keys.

  • Avatar of Andrew S.
    Andrew S.
    ·
    ·

    Vs the number of times buckets of values were selected

  • Avatar of Johannes K.
    Johannes K.
    ·
    ·

    Thanks for that. Sorry Andrew S. I was travelling. In your case, do you have to change the datatype or does it arrive as a List like it does in your screenshot?

  • Avatar of Andrew S.
    Andrew S.
    ·
    ·

    I did not have to change my datatype. It's how the list results present

  • Avatar of Johannes K.
    Johannes K.
    ·
    ·

    Okay thanks. In my case the objects come in an array. I.e. there are many key:value pairs which is why this might not work for me. Have to look at how the data is sent. Thanks

  • Avatar of Andrew S.
    Andrew S.
    ·
    ·

    Double check it was submitted as object lists and not just a string array. Check the icon next to the property name

  • Avatar of Johannes K.
    Johannes K.
    ·
    ·

    Andrew S. still stuck on this a little. Do you mind sharing with me how exactly your list looks like? As in, the raw data. Mine looks like this and I suspect we have formatted it incorrectly.

  • Avatar of Andrew S.
    Andrew S.
    ·
    ·

    Lists look like:

    "guidedrec_choice_ids": [
          5670,
          5707,
          5734
        ],

    and object lists look like:

    "guidedrec_choices": [
          {
            "id": 5670,
            "text": "Red"
          },
          {
            "id": 5707,
            "text": "Rich and unctuous stew"
          },
          {
            "id": 5734,
            "text": "Floral"
          },
          {
            "id": 6960,
            "text": "Vanilla-flavoured"
          }
        ],

  • Avatar of Johannes K.
    Johannes K.
    ·
    ·

    the guiderec_filters from your screenshot is coming from one of those lists? Thank you for posting this. Good for me too see 🙏

  • Avatar of Andrew S.
    Andrew S.
    ·
    ·

    yes. I looked at it in "json" format in the version I pasted as text.

  • Avatar of Johannes K.
    Johannes K.
    ·
    ·

    okay, mine are coming in as a string. I just saw this in the Lexicon. Even though at a glance they look to be formatted like yours.

  • Avatar of Andrew S.
    Andrew S.
    ·
    ·

    I had mixpanel-bot write out an example of the tracking in JS implementation for a list of objects. So you can check your code to see if there is something that is not like this and therefore passing as a string hiding a json object in plain sight. Usually a missing [ ] in the tracking code.

  • Avatar of Johannes K.
    Johannes K.
    ·
    ·

    Thank you!