Sign In Register

How can we help you today?

Start a new topic
Answered

Segment Queries behaviour

Hello,


I have a question regarding the whole segment system and the segment queries. From what I understood, the segment query system is a dynamic ruling agent automatically sorting the players in the pre-defined segments.

 

The description says :

"Segment Queries allow you to define the dynamic rules that are used to determine a players membership to a given segment. These rules are evaluated at runtime and the players inclusion into a segment may change when their state changes."


However, I couldn't get it to work so far.  It seems to be lacking some logic functions in order to automatically sort users.


1.) How do you link segment queries to segments ? Is there a special naming convention ?

2.) Is this fired automatically ?

3.) If it is, when is it fired at runtime ?


Thank you,


Best Answer

Hi Buche


I've set up a basicexample to show you how it works.


First go to Segments and create a Segment like this. We'll add players to this Segment when we want to charge the higher price for a certain good.




Next we'll set up the Segment Query, this query is looking for people with a "price_Seg" equal to "highPrice_SEG"




Next create an event called priceSegment and add this Cloud Code to it "Spark.getPlayer().setSegmentValue("price_Seg", "highPrice_SEG");" This will simply add the current player sending it to the high price segment.


Now lets create our Virtual Good, I created one called GOLD and gave it a standard price of 10 (currency1) and a High Price Segment price 50 (currency1)




Now create a player, credit them 100 of currency 1 (via an event or in the player management screen), then do a BuyVirtualGoodsRequest with currency & quantity set to 1 and a shortCode of 1, this player will be debited 10 of currency 1


Now create a second player, have them send the "priceSegment" event to set them to the high price segment, then credit them 100 of currency 1 ( again via an event or in the player management screen), then do a BuyVirtualGoodsRequest with currency & quantity set to 1 and a shortCode of 1, this player will be debited 50 of currency 1 as they are in the high price segment. With this system you'll be able to set up multiple Segments and set prices accordingly. Using Spark.getPlayer().setSegmentValue will enable you to add players to Segments whenever you want. You could add certain players to a Segment that gives them %20 off Virtual Goods when they have hit a certain level for example. If you have any more questions just let me know.


Thanks,

Liam


Answer

Hi Buche


I've set up a basicexample to show you how it works.


First go to Segments and create a Segment like this. We'll add players to this Segment when we want to charge the higher price for a certain good.




Next we'll set up the Segment Query, this query is looking for people with a "price_Seg" equal to "highPrice_SEG"




Next create an event called priceSegment and add this Cloud Code to it "Spark.getPlayer().setSegmentValue("price_Seg", "highPrice_SEG");" This will simply add the current player sending it to the high price segment.


Now lets create our Virtual Good, I created one called GOLD and gave it a standard price of 10 (currency1) and a High Price Segment price 50 (currency1)




Now create a player, credit them 100 of currency 1 (via an event or in the player management screen), then do a BuyVirtualGoodsRequest with currency & quantity set to 1 and a shortCode of 1, this player will be debited 10 of currency 1


Now create a second player, have them send the "priceSegment" event to set them to the high price segment, then credit them 100 of currency 1 ( again via an event or in the player management screen), then do a BuyVirtualGoodsRequest with currency & quantity set to 1 and a shortCode of 1, this player will be debited 50 of currency 1 as they are in the high price segment. With this system you'll be able to set up multiple Segments and set prices accordingly. Using Spark.getPlayer().setSegmentValue will enable you to add players to Segments whenever you want. You could add certain players to a Segment that gives them %20 off Virtual Goods when they have hit a certain level for example. If you have any more questions just let me know.


Thanks,

Liam

Hey Liam,


Thanks for the detailed example. That's basically how I understood the segments so far. I'm actually aiming to use them for property sets (in order to A/B test some in-game tweaks).

What tickled me was that the segment queries description made it look like GS had a built in dynamic ruling system. (i.e. If a player falls into a segment conditions, the system automatically assigns the player to the segment).


So we do have to manually assign segments by creating those rules ourselves, right ?


Thank you,



Hey Buche,

Yes you would have to write some cloud code to have your players assigned into those segments based on whatever criteria you want.
We are working on a new feature called experiments which are closer to A/B testing and will group players based on the filter criteria. However, this is still in beta and we are still working on documentation for it.

Sean

 


1 person likes this

Hey Sean,


Great news, thanks for the heads up. Do you have an ETA for the experiment system ? That's exactly what we are looking for.


Thank you for your time,

 If you go to the Manage Tab in the portal, you should see the 'Experiments' option.
Bear in mind this is still being worked on, so i cannot guarantee that it will work how you want it to and we currently dont have any documentation on it, but feel free to tinker and ask questions about it.

Sean

Yes I saw this tab and worked on it a bit. I meant "what's the ETA for the final version". 


For now, I've tried to use it for properties but they do not seem to appear in the "A/B testable" variant data. All I can work on are messages, achievements, leaderboards and virtual goods. Is there a way to get the properties or property sets in there ? (I would like to be able to A/B test custom data).


Thanks,

we dont currently have an eta on this as it is an on-going feature, rather than a once-off feature request, but i will keep you updated.

 

Hi@all,


want to reactivate this topic because, it is a little bit confusing to me, how i get a list of all players that I set to my segments.


The plan is to structure my levels into segments. Depending in which level the Player are, there will be different data, currencies,  leaderboards etc.


Is it possible to make a search with the segments query ?


It is really hard to become a feel for this huge backend beside my coding skills.


Thx for the help

Andi





I have solved the problem myself.

First i set players to segments representing Lobbys. When Enter the Segment/Lobby  i store the playerdetails in a Lobby runtime Collection.
This Collection i can query which players actually in that specific Lobby. On exit i drop the Playerdetails from the Collection..

Andi

 

Login to post a comment