Created
March 5, 2012 21:22
-
-
Save wheeyls/1981187 to your computer and use it in GitHub Desktop.
resize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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