Hello Diogo,

Segment conditions (mostly) operate on profile and session properties. So
you have basically the following options:
- add a rule and a custom action to copy the event properties you need to
the profile properties and then you can simply build a segment that has
condition on the "new" profile properties. It is also possible to use
scripting to avoid having to develop a custom action (see example below).
- use a PastEventCondition to build a condition that matches if profiles
have received such a condition in the past

The most scalable and performant solution is the first one, but it requires
a little more work since you need to provide a rule and an potential action
implementation. The second solution can be done with out of the box
components but it can have performance issues if you don't properly limit
the condition in time and size.

Here is an example of using a rule

{
  "metadata": {
    "id": "incrementPageViewCount",
    "name": "Increment page view count",
    "description": ""
  },
  "raiseEventOnlyOnceForSession": false,
  "condition": {
    "parameterValues": {
      "subConditions": [
        {
          "type": "pageViewEventCondition",
          "parameterValues": {}
        },
        {
          "type": "eventPropertyCondition",
          "parameterValues": {
            "propertyName": "scope",
            "comparisonOperator": "exists"
          }
        }
      ],
      "operator": "and"
    },
    "type": "booleanCondition"
  },
  "actions": [
    {
      "parameterValues": {
        "setPropertyName": "properties.pageViewCount",
        "setPropertyValue": "script::r =
profile.properties['pageViewCount']; if (r == null) {
profile.properties['pageViewCount'] = [];
profile.properties.pageViewCount = [event.scope : 1] } else { if
(r[event.scope] != null) { r[event.scope] = r[event.scope] + 1 } else
{ r[event.scope] = 1 }} r",
        "storeInSession": false
      },
      "type": "setPropertyAction"
    }
  ]
}

Here's an example of using a PastEventCondition in a segment:

{
  "itemId": "pastEventConditionExample",
  "itemType": "segment",
  "version": 1,
  "condition": {
    "parameterValues": {
      "numberOfDays": 30,
      "eventCondition": {
        "parameterValues": {
          "pagePath": "/sites/digitall/home/investors"
        },
        "type": "pageViewEventCondition"
      },
      "minimumEventCount": 1,
      "maximumEventCount": 6,
      "generatedPropertyKey": "pastEventConditionExampleProperty"
    },
    "type": "pastEventCondition"
  },
  "metadata": {
    "id": "pastEventConditionExample",
    "name": "Past event condition example",
    "description": null,
    "scope": "digitall",
    "tags": [],
    "systemTags": [],
    "enabled": true,
    "missingPlugins": false,
    "hidden": false,
    "readOnly": false
  }
}

I hope this will help.

Best regards,
  Serge...


Serge Huber
CTO & Co-Founder
T +41 22 361 3424
9 route des Jeunes | 1227 Acacias | Switzerland
jahia.com <http://www.jahia.com/>
SKYPE | LINKEDIN <https://www.linkedin.com/in/sergehuber> | TWITTER
<https://twitter.com/sergehuber> | VCARD
<http://www.jahia.com/vcard/HuberSerge.vcf>


> JOIN OUR COMMUNITY <http://www.jahia.com/> to evaluate, get trained and
to discover why Jahia is a leading User Experience Platform (UXP) for
Digital Transformation.

On Wed, Jun 6, 2018 at 12:19 AM, Diogo Munaro Vieira <
[email protected]> wrote:

> Hey guys,
>
> I'm sending events for Unomi and it's working pretty well! But I don't know
> how can I build segments with these event's properties. Here an example of
> a event:
>
> {
> "source": {
> "itemId": "webpage",
> "scope": "systemscope",
> "itemType": "page"
> },
> "events": [{
> "eventType": "pageview",
> "source": {
> "itemId": "my page",
> "scope": "systemscope",
> "itemType": "page"
> },
> "scope": "systemscope",
> "target": {
> "itemId": "http://www.globo.com/";,
> "scope": "systemscope",
> "itemType": "page",
> "properties": {
> "referrer": "https%3A%2F%2Fwww.globo.com%2F",
> "timestamp": "1528222422907",
> "object": "http://www.globo.com/";,
> "host": "177.200.196.180",
> }
> }
> }]
> }
>
>
> I'm trying to create segments using this curl and getting
> NullPointerException even at karaf log:
>
> curl -iv -u karaf:karaf -H 'Content-Type: application/json' --insecure
> https://localhost:9443/cxs/segments -X POST -d '{"metadata": {"id":
> "globo","name": "Globocom","scope": "systemscope","description": "All home
> users.","readOnly": true},"condition": {
>                     "parameterValues": {
>                         "propertyName": "target.properties.object",
>                         "comparisonOperator": "equals",
>                         "propertyValue": "http://www.globo.com/";
>                     },
>                     "type": "eventPropertyCondition"
>                 }}'
>
> What am I doing wrong?
>
> Thank your for your attention,
> --
> Diogo Munaro Vieira
>

Reply via email to