Skip to content

Instantly share code, notes, and snippets.

@TexRx
Forked from robtarr/resize.js
Last active April 4, 2023 18:28
Show Gist options
  • Save TexRx/5304511 to your computer and use it in GitHub Desktop.
Save TexRx/5304511 to your computer and use it in GitHub Desktop.
(function(w) {
var resizeTimer
, $win = $(w);
// Assuming we have jQuery present
$win.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)
*/
_gaq.push( [ "_trackEvent", "User Actions", "Browser Resize", $win.width() + " x " + $win.height() ] );
}, 1000);
});
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment