Jump to content
  • entries
    943
  • comments
    5,899
  • views
    924,392

Using analytics in your game


Josh

3,390 views

 Share

blog-0604463001481991098.jpg

As noted previously, Leadwerks 4.2 now support built-in analytics. To enable this in your game you need to create an account at www.gameanalytics.com and create a new product. You can find your keys on the Game Settings page.

 

blogentry-1-0-28405700-1481989556_thumb.jpg

 

At the beginning of the main lua script, some code has been added to initialize analytics. By default this is commented out:

if DEBUG==false then
   Analytics:SetKeys("GAME_KEY_xxxxxxxxx", "SECRET_KEY_xxxxxxxxx")
   Analytics:Enable()
end

 

Uncomment this and insert your game's game key into the first argument. Insert your secret key into the second argument.

 

The main Lua script has already been set up to record a progress event when the player starts your level, and another when they complete it. Below the initial map loading code, a progress event is sent indicating the player has started the level:

--Load a map
local mapfile = System:GetProperty("map","Maps/start.map")
if Map:Load(mapfile)==false then return end
prevmapname = FileSystem:StripAll(changemapname)

--Send analytics event
Analytics:SendProgressEvent("Start",prevmapname)

 

When a new map is loaded in the game loop, another event is sent to indicate that the previous level was completed, and the new level is beginning:

--Send analytics event
Analytics:SendProgressEvent("Complete",prevmapname)

--Load the next map
if Map:Load("Maps/"..changemapname..".map")==false then return end
prevmapname = changemapname

--Send analytics event
Analytics:SendProgressEvent("Start",prevmapname))

 

The FPSPlayer script has a new line of code in the OnDead() function that sends an event indicating the player failed to complete the level:

if type(prevmapname)=="string" then Analytics:SendProgressEvent("Fail",prevmapname) end

Viewing Data

Once your game has accumulated enough data, you can look at your results in the Explore section and clicking on Look up metric. Your progress events will be shown here.

 

blogentry-1-0-94205800-1481990483_thumb.jpg

 

You can even set up a custom funnel in the gameanalytics.com web interface, which will give you a better visualization of player progress through your game.

 

blogentry-1-0-09076100-1481993840_thumb.jpg

Interpreting Data

If you see a lot of people starting a level, but few are finishing it, it may indicate your game is too hard, or the objective is not clear. If there is a large number of failed attempts, consider reducing the difficulty. If there is just a lot of starts and no completes, maybe the player is just bored. If you see some trouble spots in your game, try making changes, collect new data, and see if your changes improve the user experience.

 

Most importantly, you need a good amount of players in order for any analytics data to be useful. A sample size of 20 is statistically significant, and gives you enough information to make decisions. Analytics will give you objective data and help reveal problems you might not otherwise realize, but you need to have a fun game people like playing in order to collect the data in the first place.

 

MartyJ was a huge help in figuring the implementation of this out.

  • Upvote 7
 Share

14 Comments


Recommended Comments

So if DEBUG is true and those keys don't get set and it's not enabled, calls to it won't error out? They are ignored I assume?

Link to comment

Yes. I did not want to have an if statement for every single analytics event call, so if analytics are not enabled the function just returns false.

Link to comment

I know how to do this with C but how do Lua users get which user is submitting data, especially between different game sessions? I know you used the Steam ID for the editor but can Lua users do that?

Link to comment

I know how to do this with C but how do Lua users get which user is submitting data, especially between different game sessions? I know you used the Steam ID for the editor but can Lua users do that?

 

If Steamworks is initialized, the SteamID is used. I considered scrambling this to "protect" the user, but in the end I decided there might be some future benefit to having the user's analytics data and forum account both linked to the same ID. I don't know if that will ever really be useful, but I think I am safe using the plain SteamID, and the user can always turn the feature off if they don't want that.

 

If Steamworks is not initialized, a unique user ID is generated and saved in the game's config file.

 

You do not ever need to be interested in a single user's data. I'm not even sure if you can access that, other than in the Live tab which only shows the raw data of the last ten received events. The only information of value to you is the whole player base.

Link to comment

I was thinking of the scenario where you receive 9 pieces of data that people didn't get past the first boss but 1 person did. Well, that could be anything, right? It could all be the same 1 person trying a boss 10 times or 1 person failing 9 times and 1 other one getting it the first time. Or anywhere in between. So to me, just raw data of attempts and failures is not enough. It needs to be shown per person.

 

Just like with the editor, is it 1 person creating 100 boxes or 100 people creating 1 box each? There's a major difference.

Link to comment

I was thinking of the scenario where you receive 9 pieces of data that people didn't get past the first boss but 1 person did. Well, that could be anything, right? It could all be the same 1 person trying a boss 10 times or 1 person failing 9 times and 1 other one getting it the first time. Or anywhere in between. So to me, just raw data of attempts and failures is not enough. It needs to be shown per person.

 

Just like with the editor, is it 1 person creating 100 boxes or 100 people creating 100 boxes? There's a major difference.

Yeah, but given enough data all the outliers will cancel out. There will be one statistically insignificant freak, but his effect will be overwhelmed by the majority of data.

Link to comment

Does this work when running from the editor? Just added it to my winter game, but perhaps I need to be more patient. Currently not seeing anything yet in game analytics.

Link to comment

It takes 15-45 minutes for events to appear on the "Live Feed" page. The dashboard and explore pages only update once a day.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...