Ever wonder what Java version your website visitors have installed? Here's how you can leverage Google Analytics to find out:
- Locate the Google Analytics script in your HTML page (you must be using the new "ga.js" version). Here is what mine looks like:
<script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-XXXXX-X"); pageTracker._initData(); pageTracker._trackPageview(); </script>
- Insert the following code after that script:
<script src='http://java.com/js/deployJava.js' type='text/javascript'></script> <script type='text/javascript'> var jreVersions = deployJava.getJREs(); if (jreVersions.length==0) pageTracker._setVar("Java: none"); for (var i=0; i<jreVersions.length; ++i) pageTracker._setVar("Java: " + jreVersions[i]); </script>
- Please note, if you are using Blogger you will need to encode the '<' character as "<". Open up Error Console in your browser to double-check that the script is not generating any errors.
- Wait 24 hours for Google to update the report.
- View the updated data at Google Analytics -> Visitors -> User Defined.
- There are two ways to drill-down based on user-defined values:
- Advanced Segments -> New -> Dimensions -> Visitors -> User Defined. For example:
- Track users without Java: Matches Exactly: "Java: none"
- Track users with Java: Starts With: "Java:" and Does Not Match Exactly: "Java: none"
- Track users with Java 1.6: Starts With: "Java: 1.6"
- You can then check how many Flash users also had Java installed. Or how many Windows users had Java 1.6 installed. Or the connection speed of Java users.
- Visitors -> User Defined -> [Pick One] -> Dimension. For example, you can now click on Java: 1.6.0 -> Dimension -> Browser to find out what browsers visitors with Java 1.6.0 were using.
- Publish your results here: http://forums.java.net/jive/thread.jspa?messageID=317425