2

Say my event looks like:

purchase = {
   items: ["pickle", "turtle", "lexicon"]
}

How do I count how many events have "pickle"?

Community
  • 1
  • 1
Michelle Wetzler
  • 734
  • 4
  • 16

1 Answers1

2

Use the equal operator.

var count = new Keen.Query("count", {
  event_collection: "purchases",
  timeframe: "this_14_days",
  filters: [
    {
      property_name: "items",
      operator: "eq",
      property_value: "pickle"
    }
  ]
});

From the API reference for filters & their operators:

“Equal to” – Note that if your property’s value is an array, “eq” can be used to filter for values inside that array. For example, eq: 5 will match a value of [5, 6, 7].

Michelle Wetzler
  • 734
  • 4
  • 16