I made some changes in the rule/action payload, as you can see below:
{
"metadata": {
"id": "incrementPageViewCount",
"name": "Increment page view count",
"description": ""
},
"raiseEventOnlyOnceForSession": false,
"condition": {
"parameterValues": {
"subConditions": [
{
"type": "pageViewEventCondition",
"parameterValues": {}
},
{
"type": "eventPropertyCondition",
"parameterValues": {
"propertyName": "target.properties.object",
"comparisonOperator": "exists"
}
}
],
"operator": "and"
},
"type": "booleanCondition"
},
"actions": [
{
"parameterValues": {
"setPropertyName": "properties.pageview",
"setPropertyValue": "script::r = profile.properties.pageviews; if (r ==
null) { profile.properties.pageviews = []; profile.properties.pageviews =
[event.properties.object : 1] } else { if (r[event.properties.object] !=
null) { r[event.properties.object] = r[event.properties.object] + 1 } else
{ r[event.properties.object] = 1 }} r",
"storeInSession": false
},
"type": "setPropertyAction"
}
]
}
When I try to send an event that matches with those conditions, I get a 500
and this error: [Error: could not access: pageviews; in class:
java.util.LinkedHashMap]\n[Near : {... r = profile.properties.pageviews;
....}]
Is this intended? I'm pretty sure we're doing the check if it is null then
create it, just like your example.
2018-06-06 14:23 GMT-03:00 Gabriel Cardoso <[email protected]>:
> PS: if I organize it like the example i gave:
> "pageviews": {
> "globoesporte.com/" : 1,
> "globoesporte.com/futebol" : 3,
> "globoesporte.com/futebol/flamengo" : 10
> }
>
>
> can I refer to it when creating a segment like: "properties.pageviews['
> globoesporte.com/']"?
> or every key name should be compliant to dot terminology?
>
> sorry about the double email and thanks again!
>
> 2018-06-06 14:21 GMT-03:00 Gabriel Cardoso <[email protected]
> >:
>
>> Hi Serge!
>> Let me see if I understood correctly:
>> Let's say I have a pageview event in globoesporte.com/
>> The clean way of keeping track of this is by making a profile property
>> (with a rule and action) as a count, so it increments as the user keeps
>> firing this pageview event. So I would have a profile property for each
>> page he visited (globoesporte.com/futebol, globoesporte.com/futebol/flame
>> ngo). Is this correct? Wouldn't this bloat our profile?
>> I could organize the profile property as:
>> "pageviews": {
>> "globoesporte.com/" : 1,
>> "globoesporte.com/futebol" : 3,
>> "globoesporte.com/futebol/flamengo" : 10
>> }
>>
>> so I wouldn't make it that much bloated, if you have a better approach i
>> would love to hear about it.
>>
>> Now about the decay of information: should I be worried about that number
>> never leaving the profile? I mean, it could be that after a few months "
>> globoesporte.com/futebol/flamengo" wouldn't be that relevant for this
>> user but i'm still segmenting him as a "flamengo fan". Everything related
>> to profiles would be "decayed" as set in Unomi (90 days i believe), right?
>>
>>
>> Thank you so much for your patience and answers, you're helping us a lot!
>>
>> 2018-06-06 12:11 GMT-03:00 Serge Huber <[email protected]>:
>>
>>> 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
>>> >
>>>
>>
>>
>>
>> --
>> Gabriel Cardoso
>> Ramal 6584 - (21) 96601-4664
>> Profiling@BigData
>>
>
>
>
> --
> Gabriel Cardoso
> Ramal 6584 - (21) 96601-4664
> Profiling@BigData
>
--
Gabriel Cardoso
Ramal 6584 - (21) 96601-4664
Profiling@BigData