Theo dõi thay đổi kích thước cửa sổ thông qua Google Analytics - Thủ thuật CSS

Anonim

Sparkbox có đoạn mã này để giúp tìm ra tần suất các cửa sổ trình duyệt thực sự được thay đổi kích thước.

(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); )); ))();

Lưu ý mức độ dễ dàng theo dõi các sự kiện trong Google Analytics. Nó có thể được sử dụng cho bất cứ điều gì.