I want to segment based on the “active language” which means the language key of the object where the active key is set to true. So in the example above, the active language would be de.
It doesn’t seem like there is a way to segment based on 2 keys within the same object, meaning that when I create the following segments for my active languages, this test user appears in all segments.
Is there a way to set up the segments so that this test user would only appear in the de segment and not in the otheres.
Best answer by Ramy
Hi Jan!
It is possible for you to build conditions that check for two (or more) keys within the same object. To clarify, you can construct Segment Conditions to look for:
test_attribute[0].active is equal to true and test_attribute[0].language is equal to fr
OR
test_attribute[1].active is equal to true and test_attribute[1].language is equal to fr
OR
test_attribute[2].active is equal to true and test_attribute[2].language is equal to fr
In this scenario, the first joined condition looks for the first object having both those values on those keys, failing that, the second joined condition looks for both values on the keys for the second object, and so on. The tip to do this is all about specifying the index number on each condition, so we limit our Segmentation Engine to look only within that numbered index.
Note, the first object is always at index [0].
I have to say, the validity of this solution would mainly depend on how many objects you expect this attribute to contain at maximum. Seeing this is a language attribute, I would assume this could hold 3-4 ‘langauge’ objects at max. However, if you expect some attributes to contain more objects, you’ll want to account for that number in your Segement Conditions, by adding this set of condition for the expected number of objects.
It is possible for you to build conditions that check for two (or more) keys within the same object. To clarify, you can construct Segment Conditions to look for:
test_attribute[0].active is equal to true and test_attribute[0].language is equal to fr
OR
test_attribute[1].active is equal to true and test_attribute[1].language is equal to fr
OR
test_attribute[2].active is equal to true and test_attribute[2].language is equal to fr
In this scenario, the first joined condition looks for the first object having both those values on those keys, failing that, the second joined condition looks for both values on the keys for the second object, and so on. The tip to do this is all about specifying the index number on each condition, so we limit our Segmentation Engine to look only within that numbered index.
Note, the first object is always at index [0].
I have to say, the validity of this solution would mainly depend on how many objects you expect this attribute to contain at maximum. Seeing this is a language attribute, I would assume this could hold 3-4 ‘langauge’ objects at max. However, if you expect some attributes to contain more objects, you’ll want to account for that number in your Segement Conditions, by adding this set of condition for the expected number of objects.
Sorry to hear that workaround wouldn’t work for your use case, although I surely understand the scalability concern. JSON Segmentation is still quite a new feature, which is why our Product Team is always interested in learning what use cases our customers come up with to utilize this feature. I have to say this use case is a particularly clever one that can potentially help a lot!
I have shared this use case with the Product team. While I’m afraid there is no concrete timeline we can share for this feature request, we’ll be sure to get in touch once this change is worked on and gets released into Production Environments.
Apologies for not bearing you better news on this, Jan!
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.