0

I have some event tracking on a collapsible tree that tracks each time a user expands a tree:

jQuery('ul.child-pages div.hitarea').click(function() {
    piwikTracker.trackGoal(1); // Track TreeView Clicks in Piwik when a user clicks on hitarea
});

I'm worried that this is costly on performance if I'm sending data to my server on each click. Is there a more efficient way to accomplish the same? Or am I paranoid and sending a small request to the server isn't that big of a deal (although Piwik is database driven so I'm actually writing somewhere in MySQL on every click).

Ruan Mendes
  • 90,375
  • 31
  • 153
  • 217
AlxVallejo
  • 3,066
  • 6
  • 50
  • 74
  • You could add queues at many levels. JavaScript; add events to an array in JavaScript, and submit them *N* (5?) at a time (but you'll loose events which were tracked, but never submitted before the page was closed). Server: Store them in memory (Memcached?) and save to the database periodically. The best advise is to only worry about it if it becomes a problem; and add a queue *where* the bottleneck is – Matt May 15 '12 at 16:26

1 Answers1

1

If you find it's a real concern (don't waste time if you aren't sure it's a problem), just batch the requests and send them out after a period of inactivity

Ruan Mendes
  • 90,375
  • 31
  • 153
  • 217