Web Analytics – Event Tracking

Here’s a link to the project

To add event tracking into the Spider Chase game, I used Google Analytics – a free service that allows you to see user events in real-time before displaying more in-depth statistics after 24 hours have passed.

To use Google Analytics in your website, you must include this code generated by Google in the head of your HTML document:

It was surprisingly easy to enable Google analytics on my web-page, and the instructions from Google Analytics explaining how to do so were easy to follow. Whenever you want Google Analytics to track an event on your page, you must create a gtag that contains the information that you want to track. Each gtag is made from a category, action, label and value. I used the category to denote the game that was being tracked, so that if I used Google Analytics for any future projects hosted on the same page, it would be simple to differentiate between events being generated by different games.

The event action describes what the player was doing to trigger an event to be tracked. The four tracking calls that I put into this game were die, restart, start and win. Labels are used to describe any values that you are tracking, in this instance I wanted to know how many attempts a player had, and what their score was, therefore these were the labels I used. Finally, the value is used to return any specific data points you want to track, which analytics will automatically provide average values for from your data.

To make the creation of the gtags easier, I created a small wrapper function that took in the different pieces of data needed for the tracking call as parameters and used them to generate the gtag. I set the event category as there was only one game available on the web page. By creating a wrapper function, I also minimised the risk of human error creating invalid gtags, or sending values that were not the intended variables that I wished to track.

To generate some data for Google Analytics to process, I sent a link to my game to a group of friends to try out. After 24 hours, this table was available:

By adding together start and restart calls, I can determine how many times the game was played – 15. Out of these games, 9 were lost, 4 were won and 1 exited the page before the game ended. However, if you compare this table to the Event Flow graph below, it shows that two people actually exited the game before finishing their attempt.

This shows that when looking at statistics, it is important to examine data in different formats, to minimise the risk of false assumptions. Interestingly, there is a similar exit rate regardless of if the player died or won the game, furthermore, no one successfully beat the game on their first try. There was one player who continued to play the game several times, before giving up without finishing their last attempt.

If I were to add to this project, I would want to create additional tracking calls at the end of the player’s run giving their x position, as this may indicate how far through the level the player managed to get before being caught by the spider. This information could be used to determine if there is one stumbling block that all players fall at, or if the level is uniformly difficult.