Skip to content

Instantly share code, notes, and snippets.

@roman01la
Forked from robtarr/resize.js
Created July 31, 2012 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roman01la/3218199 to your computer and use it in GitHub Desktop.
Save roman01la/3218199 to your computer and use it in GitHub Desktop.
Google Analytics Resize Tracking
(function() {
var resizeTimer;
// Assuming we have jQuery present
$( window ).on( "resize", function() {
// Use resizeTimer to throttle the resize handler
clearTimeout( resizeTimer );
resizeTimer = setTimeout(function() {
/* Send the event to Google Analytics
*
* https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiEventTracking
* _trackEvent(category, action, opt_label, opt_value, opt_noninteraction)
*/
var $window = $( window );
_gaq.push( [ "_trackEvent", "User Actions", "Browser Resize", $window.width() + " x " + $window.height() ] );
}, 1000);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment