2
votes

I'm soon to be launching an Adobe AIR desktop app. To make the best out of future updates I need to get analytics of which features get used the most and which not.

How to track what the user clicks?

3

3 Answers

3
votes

I agree with @Pranav on the methods for logging the clicks, but I totally disagree with how he wants to implement the tracking on the client side.

  • Extending the 'Button' class: violates several rules of good coding practice. But I prefer to give a practical example instead of abstract rules: what if you want to track something other than Buttons? Extend every visual component in the framework? What if you want to track something other than clicks? ...
  • Manually add the code in every click handler: seems like a lot of work if you have a larger application, plus it's hard to refactor if the need be.

Solution

If all you need is clicks, then I would just have one click listener on the stage. That way you can handle your click tracking in a class that is completely separate from the rest of your application. And you can do it any way you like. e.g. you could divide the screen into areas and see which areas are most clicked; you could use stage.getObjectsUnderPoint() to find all the objects that were just clicked (usually the topmost object is the one you want, but perhaps you want to log all of them).

Either way, you now have complete liberty in how you choose to track usage and the code is all in one place if you ever need to change anything.

1
votes

If your app is almost done, then you should be pretty familiar with AIR.

You can do your tracking in 2 ways (There must be many more, but I'm going to highlight 2 of them). Both require you extending the Button class and doing different things in your click handler, or you could manually add the code in every click handler you want to track)

First
You keep a click tracker service like clicky on your server. The click handler should call the code that is given in the documentation of the analytics code

Second
You write the feature used (or whatever else you want to track) to a log file which is then uploaded whenever an internet connection is there (Basically try to upload every 10 minutes or so and ignore any http errors). The upload script will parse the log file and then show you whatever information you require. The log file will then be erased.

0
votes

Look into using the Command Pattern. In addition to rollback, it can count instances of that command.