Speed Up Google Analytics: Use Async
Saw a great post at High Performance Web Sites blog, Google Analytics goes async. The author is Steve Souders, who works at Google on web performance. So this is from the horses mouth.
Think about it, why would you care when the Google Analytics code is loaded? All it does is capture data, as long as Google gets it — it may as well go out at midnight. The new code enables an “async” request in HTML5.
The official announcement is found at Google Code blog: Google Analytics Launches Asynchronous Tracking, for those of you uncomfortable relying on someone’s blog for new code.
You can see the official guide at: Asynchronous Tracking Usage Guide
The code snippet suggested is (replacing your account number):
[html]
<script type=”text/javascript”>// <![CDATA[
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement(‘script’);
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ :
‘http://www’) + ‘.google-analytics.com/ga.js’;
ga.setAttribute(‘async’, ‘true’);
document.documentElement.firstChild.appendChild(ga);
})();
// ]]></script>
[/html]
The real celebration should be current browsers that actually support certain HTML 5 elements. I had read somewhere that the HTML 5 timeline extends almost to 2020.
On a side note, Google has pretty much acknowledged that HTML 5 is the future, and NOT Google Gears. While cool, Google Gears has some bumps ahead that are solved by HTML 5.
Related Posts
No comments yet.
Leave a comment
Featured Posts
- HTML Fadein Fadeout: Basic Javascript/AJAX Tutorial using jQuery's fadeTo
- Basic AJAX Tutorial: Smooth Scrolling Text Marquee with a jQuery plugin
- Basic AJAX Tutorial: jQuery toggle and slide
- Hosting: How to pick a WordPress Host
- Basic jQuery Tutorial: Modify CSS classes and attributes, Hover and Toggle example
Follow Me
Email Subscription
Recent Posts
Top Commentators
- No commentators.
Archives
Tags
Blogroll
- 456 Berea St
- ActionScript 3 Design Patterns
- adactio – home of Jeremy Keith
- ajaxian
- Boxes and Arrows
- Chris Brogan
- CSS Globe
- InsideRIA
- Jarrod Michael Studios
- Mad Vertices
- NETTUTS
- Portsmouth Community Calendar
- Roomware Blog
- Signal vs. Noise
- Six Revisions
- Snook
- Style Grind
- Tiago’s Weblog
- Viget Extend
- Vitamin
- Whats the latest
- Why Banks Fail
- Woork
- zupko.info
