I’ve mentioned a few times the power of my analytics system in the Spigot community and recently in AdminCraft on Reddit. Most advertising campaigns simply track impressions and clicks. But to a server owner, we need more data than that…. We need to know who actually joined the server and continues to play!
I have designed such a system, where I can track clicks, how many joined the game server, then out of those, who stay to the day 5, 15, 30, 60 and 90 markers! I can see when campaigns generate a lot of clicks, yet low players, or worse: players who don’t actually stay.
This article will give a rough idea on how I did it incase someone is curious to implement it on their own.
I want to be straight that the implementation isn’t perfect or the most optimized, but hey it gives you data where you normally would not have data, so that’s a clear winner!
Requirements / Disclaimer
This system only works for advertising campaigns that involve website clicks. Campaigns that serve purely as a banner and a server connect address can not be realistically tracked.
My implementation all revolves around Google Analytics, but the concept can work for any form of marketing system you want to adapt it to.
You should be using analytics.js (I do not think this works with ga.js, the old Analytics system) on every page of your site.
You will also need to be an experienced developer or have one on hand.
I WILL NOT HELP ANYONE IMPLEMENT THIS. I do not do contract work / consulting services, but feel free to ask questions on Spigot IRC.
Tracking that click
First off, my system requires that all inbound campaigns need to land the user on the website. If someone see’s your server connect address and connects directly, then you can’t track that – but hey! That’s usually a FREE conversion , so don’t complain 🙂
Here is an example database table that I use:
CREATE TABLE `conversions` ( `clientid` varchar(255) CHARACTER SET latin1 NOT NULL, `convert_id` varchar(255) CHARACTER SET latin1 NOT NULL, `ip` int(10) unsigned NOT NULL, `ua` varchar(255) CHARACTER SET latin1 DEFAULT NULL, `date` int(11) unsigned NOT NULL, `lp` text CHARACTER SET latin1, `converted` tinyint(4) unsigned NOT NULL DEFAULT '0' PRIMARY KEY (`clientid`), KEY `ip` (`ip`), KEY `converted` (`converted`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
our goal is to assign a Google Analytics Client Id to every user. Additionally, I assign a unique ID to every user separate to the client ID, as some users may have addons that constantly change their Google Analytics Client ID, so this prevents inserting an entry into DB every time their client id changes.
When a user comes in and has a Google Client ID set, assign them a convert ID. then insert an entry into the database.
Explanation of fields:
- clientid: Google Analytics Client ID
- convert_id: Field you generate to associate to a session
- ip: users IP address – to be passed later to Google Analytics for conversion and match to a newly joined player
- ua: Users User Agent – to be passed later to Google Analytics for conversion
- date: current time when seen
- lp: URL the player first landed on – so you can know what web page they visited.
- converted: has this record triggered a conversion not.
So, once you have their IP and GA client ID tagged into the database off that first page load… You got them 🙂 If they join, you will know what campaign they came from.
Now that you have them in the database, you need to have a monitoring system that checks your game server. This is the trickiest part of pulling this off, as how you do this will really vary based on your servers data infrastructure.
We have a users database table that we can easily query on and find who has played in the past few hours and has not triggered conversion events. So we run a query, get the users IP address, and then look for matching conversion table entries on the same IP address that is also not marked as converted.
In the event 2 people joined on same IP from 2 diff devices, you would have 2 entries in the conversions table, and then each would match up to each other, still resulting in 2 conversions. If 2 accounts join but only 1 device hit the website, then only 1 conversion should be marked initially, but they are likely to then trigger a 2nd conversion event once they hit the website with a new device (that doesn’t match the convert_id you generated).
Now… the actual marking of a conversion when this happens!
Setting up your conversion event
Now you need to configure Google Analytics to have a goal to count the conversions.
Go to Admin > Your Property > Your Primary View > Goals
Add a new Goal using an Event like so:
This step doesn’t have to be done first, but it does need to be done to view it and there’s no benefit to do it after rather than before.
Google Analytics Measurement Protocol
The way the Google Analytics tracking system works is extensively documented, and even encouraged for you to do your own backend server side reporting of the event on behalf of the user!
Read all the documentation: Google Analytics Measurement Protocol.
Now we’ve got a list of rows from the conversion table of who joined the game server, with their GA Client Id IP and URL.
Now your backend monitoring system needs to call out to Google Analytics in the exact same fashion the client browsers do, but I’ll save you the trouble, here is the code I use to do this:
I do even further events like Day 5/15/30/60/90 tracking, so I pass in other events for those. To support that type of data, you will have to analyze your data and figure out the best way to compute who should be converted for those cases.
Tagging Every Inbound Link
Now you have the infrastructure set up, you need to ensure every direct campaign you control is tagged! This involves setting utm_* parameters on your inbound links.
Learn more about UTM Parameters
I personally use our emc.gs url shortner, then create links that redirect to pages with the utm parameters, so that I can do “reddit.emc.gs” and it will tag that link with the Reddit tracking parameters. If you want to set up a url shortener like we have, check out YourLS.
I have modified it for our needs though, making it so &gac = &utm_campaign, &gas = &utm_source and &gam = &utm_medium for quick changes of properties like reddit.emc.gs/?gam=ad-4
I suggest setting up a redirect system on your main website domain and not an alternate domain like we do, because many advertising systems dislike domain mismatches, and we had to set up empireminecraft.com/go/foo to redirect to emc.gs/foo which then redirects back to the target of emc.gs/foo just to trick some of those platforms.
Enjoy having data about your campaigns and who sends you the best traffic 🙂0