question

chris-6 avatar image
chris-6 asked

Track How Many Players Did a Specific Thing?

Hello, I'm new to PlayFab and the amount of information is overwhelming. Currently I'm looking at player statistics and am having success tracking most of the data I want to see about my game, but one particular bit of information eludes me.

I want to see how many players have done a specific thing (for example, visited a certain level). There are A LOT of levels and we want to track how many players visited each one so we can make sure there aren't levels being visited too much or levels never being visited. You don't visit these levels linearly so we can't just track "progress".

Sorry for the basic question, but I'm not even familar enough with the features to search for an answer.

apisanalytics
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brandon@uprootstudios.com avatar image
brandon@uprootstudios.com answered

Hey, so I'd imagine that the new Explorer functionality in the Game Manager would be perfect for this. You can find it in the Game Manager > Analytics > Explorer (Preview)

You can set it up like this:

Every time a player visits a level, write a custom event using WritePlayerEvent

Assuming you're using Unity, you can write a function like this and call it every time a player visits a level (replacing "Cool Level" with whatever the current level name is):

void PlayerVisitedLevel() {
    PlayFabClientAPI.WritePlayerEvent(new WriteClientPlayerEventRequest{
        EventName = "player_visited_level",
        Body = new Dictionary<string, object>{
                {"Level", "Cool Level"}}
    },
    result => {
        Debug.Log ("Wrote player event: " + result.ToJson());
    }, 
    error => {
        Debug.LogError ("Error writing player event: " + error.GenerateErrorReport());
    });
}

And then after that happens a few times, you can query the data in Explorer using a query like this:

let playerLevelCount = ['events.all'] | where FullName_Name == "player_visited_level" and Timestamp > ago(30d);
playerLevelCount
| project Entity_Id, Level = tostring(EventData.Level)
| where isnotempty(Level)
| summarize count() by Level
| sort by count_ desc
| render barchart 

Which should give you a bar chart and table of results like so (I have a different query so I just changed the names to random names):


levelexample.png (43.1 KiB)
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

chris-6 avatar image chris-6 commented ·

Thanks for the help! It works perfectly!

1 Like 1 ·
Citrus Yan avatar image
Citrus Yan answered

Hi, just like Brandon suggested, using this new Explorer functionality and writing custom events would be perfect for you to track players’ activity, you can have a try:)

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.