Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm finishing another HTML5 game, and this time I'd like to do some spying business on the players... Mostly just basic stuff: when they are playing, for how long, what upgrades they are buying the most and so on. Now, my first idea was just to collect this information during the gameplay, and then have a Javascript function fire when they close the tab/browser, and said function would send it to my server via Socket.io. This, of course, wouldn't work, because anyone who takes a look at the code would realize it and could start sending a tonne of false info which would mess up my statistics.

Questions:

  • Is there a way to effectively do this?
  • If yes, what kind of info should I be looking for, aside from stuff I already mentioned?
share|improve this question
3  
You should also ask them if they have your permission to collect this info, and indicate what kinds of stuff you're sending. –  ashes999 Apr 8 '12 at 15:34
    
Why? Do I have to, legally? –  akled Apr 8 '12 at 15:40
3  
I'm not qualified to answer legal questions. But read questions on GameDev. The backlash from not asking permission and sending data without telling users is usually enough to get people to avoid your game entirely. It's inevitable that they discover this. –  ashes999 Apr 8 '12 at 15:41
2  
There is right now a vote going on area 51 about opening a Laws & Legal Questions site. Think about committing to use it. –  user14741 Apr 9 '12 at 0:02
    
Yes! A few months ago, we were chatting here and we all agreed that it's a great idea! –  akled Apr 9 '12 at 9:44
show 1 more comment

2 Answers

up vote 3 down vote accepted

You can simply gather all the info you need into some convenient form, such as JSON or something, then send it at some stage in a XmlHttpRequest, whenever you feel is appropriate.

Yes, people COULD forge requests and send loads of crap, but they probably won't. And you can record the IP address of each recipient, and if an unlikely amount of responses come from one address, you can just disregard them all.

It is highly unlikely that you will have any problems. Those eleet haxxors have better things to do than skew your stats. Really.

share|improve this answer
    
Awesome, thanks! I'll just do some IP checks as you suggested, and some reality checks. –  akled Apr 8 '12 at 22:08
2  
Just to reiterate, since this is the winning answer: make sure you ask them before you do this. –  ashes999 Apr 9 '12 at 2:33
    
Google Analytics is a particularly easy to use API for this purpose, and works surprisingly well. Several Very Big Games are doing this, in fact. The API is not precisely the best suited to the task, but it's easy to just use that than build your own. –  Sean Middleditch Apr 9 '12 at 9:30
1  
No need to check the IP address, just store the IP addresses with your other data, if there are anomalies they can easily be removed. –  MarkR Apr 9 '12 at 10:18
add comment

Well this is much easier in a multiplayer game where things are validated but you could probably do the same thing.basically, male a log of all actions and periodically send it to the server. (or when he/she logs in or out. You could also encrypt the data or obfuscate your code. But, since you're using html it's not fool proof.

share|improve this answer
    
And then, boom, suddenly they start sending false logs. In multiplayer games, I usually choose only to send actual keypresses, only that. I can't do this here, though, it's a singleplayer game (I mean, yes, I can, but I don't really want to go that far). –  akled Apr 8 '12 at 15:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.