Guest User

Untitled

a guest
May 24th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. // definition of trackEvent method on a global object
  2.  
  3. $3N = {
  4. trackEvent : function(category, action, label, value){
  5. if (typeof(pageTracker) == "object") pageTracker._trackEvent(category, action, label, value);
  6. else if(typeof(_gaq) == "object") _gaq.push(['_trackEvent', category, action, label, value]);
  7. }
  8. };
  9.  
  10.  
  11. // example of using trackEvent in my onerror helper (which you may also want to use)
  12.  
  13. window.onerror = function(msg, url, linenumber){
  14. var handle_error = function(msg, url, linenumber) {
  15. $3N.trackEvent(
  16. "Error",
  17. msg,
  18. navigator.userAgent,
  19. linenumber
  20. );
  21. };
  22.  
  23. if ($3N.dom_ready)
  24. handle_error(msg, url, linenumber);
  25. else
  26. window.addEvent('domready', handle_error.bind(window, [msg, url, linenumber]));
  27. };
  28.  
  29. window.addEvent('domready', function() { $3N.dom_ready = true; });
Add Comment
Please, Sign In to add comment