Skip to content

Instantly share code, notes, and snippets.

@wheeyls
Created March 5, 2012 21:22
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 wheeyls/1981187 to your computer and use it in GitHub Desktop.
Save wheeyls/1981187 to your computer and use it in GitHub Desktop.
resize
// Google analytics for screen dimensions, resizing
// http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html
(function () {
var w, h, str, log;
if(typeof _gaq === "object" && _gaq.push) {
w = $(window).width();
h = $(window).height();
str = w + "x" + h;
log = function (action, label, value) {
_gaq.push(["_trackEvent", "ScreenDimensions", action, label, value]);
};
log("onload", str, w);
// only one event per resize
$(window).bind("resize", debounce(function () {
var new_w = $(window).width(),
new_h = $(window).height();
log("resizeTo", new_w + "x" + new_h, new_w);
}, 2000));
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment