BUG: Flash Google Analytics trackEvent

Today I was integrating with Google Analytic's Flash codebase and ran into a bug that had me running up against a wall for about 45 minutes. It was a simple bug, but no details bubbled up from the code base to let me know what was occurring. I'm noting it here for everyone else's sanity. If you want to skip all the details and just know the cause jump down to the end of the post.

SYMPTOMS
I had set up my analytics package all via code and made a simple track call.

For the sake of this example, it looked equivalent this

Actionscript:
  1. import com.google.analytics.GATracker;
  2.  
  3. // setup tracker
  4.  var tracker:GATracker = new GATracker(this, "UA-111-222", "AS3", true);
  5. // make simple track event with a numeric value
  6.  tracker.trackEvent("MyCategory", "MyEvent", "Title1", 10.5);

Very simple right? I had followed examples online and on the surface it all appeared to work correctly. I could see the calls in the visual debugger working exactly how I wanted. However, when looked to see if the calls were going to the server with a packet sniffer, no dice! Nothing was going through. I checked my code about 500 times, looked to see if trackEvents were just beta, and tried to find out if I wasn't setting something for production.

DEBUGGING
I couldn't find anything. It wasn't until I switched the call to trackPageview that it started to go through. That worked. I decided to take the numeric value out of the call for the trackEvent call, since that was a variant between trackEvent and trackPageview. Ching, ching, little winner. Everytime I added it back in it failed silently and didn't call the server. I then noticed that the number was a fraction and not a Integer (even though the call's signature has it as Number). Therefore I decided to round the fraction everytime, and triple ching, we had the final winner.

CAUSE
The bug turned out to be that trackEvent can only take Integers as the numeric value in it's call. If you make calls using trackEvent you must round all numbers going in or the calls will not be sent out to the server.

Hope this helps with some folks headaches. Also if you ever have a bug with no details, follow the example above and work backwards. Looking at variants and testing multiple inputs you can find the root.

  1. #1 by Aran - March 3rd, 2009 at 17:48

    Kenny, I have logged a bug for you:

    http://code.google.com/p/gaforflash/issues/detail?id=46

  2. #2 by Kenny Bunch - March 3rd, 2009 at 18:20

    Thanks Aran! At the least it should be an Int as the param and throw an error if it is something else.

  3. #3 by zwetan - March 4th, 2009 at 02:08

    even if we read MXNA we are morel ikely to catch a problem on the google groups or the issues, than on blog post

    we’ll check that, but this integer limitation could be also a back-end thing

  4. #4 by Berkay Sözbilir - August 30th, 2009 at 11:14

    thanks ken. it’s good. :)
    i can try.

(will not be published)
Submit Comment
Subscribe to comments feed
  1. No trackbacks yet.