Have a question?

Segmentation Filters

Analytics are great because they provide answers to all sorts of questions:

  • How many people visited my Website?
  • When did they visit?
  • Where did they come from?

But while analytics give us some answers, they also create many more questions:

  • Of the people who came to the site, how many visited from the US?
  • Of the US visitors, how many came from search engines?
  • And how much items were purchased by just those visitors?
  • Segmentation allows you to narrowly focus attention on only the visitors you want to analyze, and probe deeper to make better decisions.

Segments

Segments consist of two parameters: are (who they are) and did (what they did) and each segment contains an operator and a list of filters. Reports and Searches support a segments and they consist of an array of the segments defined below.

 {
  "are": {
    "operator": "AND", // AND or OR
    "filters": []
  },
  "did": {
    "operator": "AND", // AND, OR or THEN
    "filters": []
  }
}

Are Filters

The are filters are simple constraints that cover the Custom Visitor Data. This filter below will narrow the query response down to those from companies that have more than 300 employees and are at the trial stage.

are: {
    "operator": "AND",
    "filters": [{
        "scope": "visitors",
        "name": "company size",
        "match": "gte",
        "value": 300 
    }, {
        "scope": "visitors",
        "name": "stage",
        "match": "match",
        "value": "trial" 
    }]
}

Did Filters

Every did filter consists of 4 objects:

  • action
  • aggregation
  • timeframe
  • visit

Action

Action defines the action targetd in this behavioral filter. For example, if you want to filter people who made a payment, the action object should define the action payment and its constrains.

action:{
    "operator": "AND",
    "filters": [{
        "scope": "actions",
        "key": "name",
        "match": "match",
        "value": "payment"
    }, {
        "scope": "actions",
        "key": "amount",
        "match": "gt",
        "value": "10"
    }]
}

Aggregation

The action constraints are extended with aggregation rules which must be matched. For example, you may want to spot people who committed the action `payment` at least 3 times, or those people who committed the action `payment` where the sum of `amount` (which is a property inside every `payment` action) to be greater than $100.

Count aggregation example

The method count takes scope as an extra parameter which is action by default. It enabled you to count occurences by actions or limiting the count to one per visit.

aggregation: {
    "method": "count",
    "scope": "actions", // or visits (to count once per visit)
    "match": "gte", // equivalent to "greater than or equals" or "at least"
    "value": 3
}

Sum aggregation example

The method sum takes an extra parameter titled `by` which is the target key that should be used to sum amounts. For example, in a payment event, you need to use the amount key.

aggregation: {
    "method": "sum",
    "by": "amount", // property of the action matching in "actions"
    "match": "gte", // equivalent to "greater than or equals" or "at least"
    "value": 100
}

Timeframe

You must define a time frame for every behavioral filter. Time frames can be defined using one of 2 methods: relative dates (days ago) and absolute dates.

Example of a relative time frame

The example below defines a timeframe relative to the time you’re querying the Woopra engines: From 29 to 0 days ago. Which means last 30 days including today.

timeframe: {
    "method": "relative",
    "from": 29,
    "to": 0
}

Example of an absolute time frame

The example below defines a timeframe that is absolute. You must define two dates in the format of yyyy-mm-dd.

timeframe: {
    "method": "absolute",
    "from": "2013-01-01",
    "to": "2013-01-31"
}

Visit

The visit parameter defines the visit constraints that should be matched. If a visit that contains a matching action but does not match with the visit constraints, the matching actions will be ignored. The visit constraints object consists of two properties: operator<code> and <code>filters.

visit: {
    "operator": "AND",
    "filters": [{
        "scope": "visits",
        "key": "browser", 
        "match": "contains",
        "value": "chrome"
    }]
}

here.

Match Comparators

Type Description key
string Exactly Matches match
string Starts With starts
string Contains contains
string Ends With ends
string Does Not Match notmatch
string Does Not Start With notstarts
string Does Not End With notends
string Does Not Contain notcontains
string Regular Expression regexp
string Empty empty
string Not Empty notempty
number Equals eq
number Less Than lt
number Greater than gt
number Greater Than or Equals gte
number Less Than or Equals lte
number Not equals neq

Full Segment Example

segments: [{
    "are": {
        "operator": "AND",
        "filters": [{
            "scope": "visitors",
            "name": "company size",
            "match": "gte",
            "value": 300
        }, {
            "scope": "visitors",
            "name": "stage",
            "match": "match",
            "value": "trial"
        }]
    },
    "did": {
        "operator": "AND",
        "filters": [{
            action: {
                "operator": "AND",
                "filters": [{
                    "scope": "actions",
                    "key": "name",
                    "match": "match",
                    "value": "payment"
                }]
            },
            aggregation: {
                "method": "sum",
                "by": "amount", // property of the action matching in "actions"
                "match": "gte", // equivalent to "greater than or equals" or "at least"
                "value": 100
            },
            timeframe: {
                "method": "relative",
                "from": 29,
                "to": 0
            },
            visit: {
                "operator": "AND",
                "filters": [{
                    "scope": "visits",
                    "key": "city",
                    "match": "match",
                    "value": "San Francisco"
                }]
            }
        }]
    }
}]

Need any help? Contact our Data Jedis