Mixpanel Community Icon

JS Event Tracking Syntax for Key/Value Pair Objects

·
·

Can you please write out the syntax for a JS implementation of an event tracking where the event has a property which is a list of objects, such as key/value pairs

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Hi Andrew S., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> đź‘‹

    Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Certainly! I can provide you with an example of how to implement event tracking in JavaScript where the event has a property that is a list of objects. This is particularly useful for scenarios like tracking items in a shopping cart or search results. Here's an example based on the Mixpanel JavaScript SDK: LBKSmixpanel.track("Product Added", { "cart": [ { "brand": "Puma", "category": "Jacket", "price": 30 }, { "brand": "Adidas", "category": "Hats", "price": 15 } ] });LBKSIn this example, we're tracking an event called "Product Added" with a property called "cart" that contains a list of objects. Each object in the list represents an item with properties like "brand", "category", and "price".It's important to note that Mixpanel has some limitations on list of objects properties: 1. The property is limited to 8KB for event properties. 2. Each object can have a maximum of 255 keys. 3. By default, only the first 5 objects within the list will be parsed in the Mixpanel UI.For more details on list of objects property support, you can refer to the Mixpanel documentation on List of Objects Property Support.

    kapa.ai is still learning and improving, please let me know how I did by reacting below.

    ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.