Google Analytics and IPv6 Capability Tracking

If you have set up a Google Analytics account and added the IPv6 Capability Test to your web pages, then this document describes where to find the IPv6 capability data in the Google Analytics reports.

The dashboard of the Analytics reports looks a lot like this:



Expanding the Contents section of the report produces the following menu:



Open the Event Tracking report and "view all" Event Actions:



This is the additional report section that is added by the IPv6 Capability Test code. There are 5 Events, and each Event has the subclasses of "yes" and "no".



Event ActionExplanation
dual:yes/noThe client can/cannot retrieve a dual stack URL
ipv4:yes/noThe client can/cannot retrieve a IPv4-only URL
ipv6:yes/noThe client can/cannot retrieve a IPv6-only URL
v6lit:yes/noThe client can/cannot retrieve a IPv6-only URL where the URL is the IPv6 address (i.e. no DNS query is used)
v6dns:yes/noThe client can/cannot retrieve a dual stack URL where the DNS A and AAAA records are served by an IPv6-only DNS nameserver
summary:valueThe number of clients who have a particular combination of capabilities.
 Value  Capability 
  V6 Literal  V6 DNS  Dual Stack  IPv6  IPv4 
0     
1     YES 
2    YES  
3    YES  YES 
4   YES   
5   YES   YES 
6   YES  YES  
7   YES  YES  YES 
8  YES    
9  YES    YES 
10  YES   YES  
11  YES   YES  YES 
12  YES  YES   
13  YES  YES   YES 
14  YES  YES  YES  
15  YES  YES  YES  YES 
16 YES     
17 YES     YES 
18 YES    YES  
19 YES    YES  YES 
20 YES   YES   
21 YES   YES   YES 
22 YES   YES  YES  
23 YES   YES  YES  YES 
24 YES  YES    
25 YES  YES    YES 
26 YES  YES   YES  
27 YES  YES   YES  YES 
28 YES  YES  YES   
29 YES  YES  YES   YES 
30 YES  YES  YES  YES  
31 YES  YES  YES  YES  YES 

For an IPv4-only client, the summary value would be 5. For an IPv4-only client with IPv6 DNS capability, the summary value would be 13. For a fully functional dual stack client, the summary value would be 31.

The "Total Events" is the number of clients who were able to undertake each of the capability tests. It is noted that the capability tests use a per-client cookie that limits the client to undertake the test suite no more often than once every 24 hours, so the sum of the yes and no test events for each test type may be lower that the total number of 'visitors' or 'Events" recorded by Analytics.



It is also possible to use other client data gathered by Analytics to provide breakdown of the clients by browser, operator system, etc.



Event Values

The event values shown in this report are client-based event timers. When the client executes this script timers are set up for the fetch of the IPv4, Dual Stack, and Ipv6 objects. Upon completion, the time for the IPv4 retrieval is set as the "base" time, ith a value of zero, and the other timers are reported as relative to this time. So, for example, if the average additional delay in fetching the IPv6 object was 213 ms longer than the retrieval time of the Ipv4 object, then the Avg. Value of the ipv6:yes Event would be reported as 213.



Advanced Scripting

It is possible to add additional features to this script. The basic form of the script just sets the variable 'ipproto_user' to a user value. It is possible to alter the invocation on the javascript on the web page to invoke additional tests and alter the bavaviour of the script. The full set of parameters are show in the following alternative script invocation:

// enable the APNIC IPProtoTest and feed google analytics events
  if ('http:' == document.location.protocol) {

   var ipproto_user = '111111';          // the user variable provided at http://labs.apnic.net
                                        // default state of the options.
   var ipproto_opts = {
     'docookies'        : true,         // test based on noCheckInterval in cookie
     'noCheckInterval'  : 86400000,     // interval to test on, if docoookies is true
     'dov6dns'          : true,         // test v6 dns to a dual-stack URL
     'dov6literal'      : true,         // test a v6 literal URL
     'dotunnels'        : false,        // test for 6to4 and teredo tunnels
     'randomize'        : false,        // by default, sorted test order
     'sampling'         : 1,            // 1/sampling eg sampling=4 1/4th tested
     'userId'           : ipproto_user, // what to log in the collector website 
     'callback'         : function_name // prototype function to receive callback of results
   };

If docookies is set to "false" the test will be performed every time each client visits this web page. This may bias your analytics reports towards the IPv6 capabilities of the most frequent visitors to the site. If docookies is set to "true", then the client is loaded with a controls the frequency of execution of this test for each client. The default value of this variable is "true".

The default value of the test frequency is once per day for each client. This can be adjusted by setting noCheckInterval to a frequency time. The unit is milliseconds, so that one day (the default value) is 86400000. The default value of this variable is 86400000.

If dov6dns is set to "true" the script will test if the client is able to cause DNS names to be resolved using DNS queries over IPv6 transport. If this is set to "false", this test will not be performed. The default value of this variable is "true".

If dov6literal is set to "true" the script will test if the client is able to retrieve an object where the domain name part of the URL is an IPv6 address literal. This test is used to expose latent Teredo capabilities on Windows hosts, where the host will not normally query the DNS for AAAA records of the only Ipv6 interface an a teredo auto-tunnel interface. If this is set to "false", this test will not be performed. The default value of this variable is "true".

If dov6tunnels is set to "true" the script will include a further 2 tests to determine the type of auto-tunnel mechanism is used by the client. The event v6stf will record the incidence of 6to4 auto-tunnelling by clients, and the event v6ter will record the incidence of Teredo auto-tunnelling by clients. The default value of this variable is "false".

If randomize is set to "true" the order in which the client performs the tests will be randomised. If this variable is set to "false" then the order of the tests will be V6-only, Dual-Stack, V4-only, V6 DNS (if enabled), V6 Literal (if enabled), V6-only with 6to4 (if enabled), V6-only with Teredo (if enabled).

If sampling is set to a value, then the test will be performed at random at a rate of 1 in sampling times. The default value of this variable is 1 (i.e. perform the tests every time the script in invoked, depending on the cookie state)

The userId is a value provided by the enrolment page at labs.apnic.net. This allows like web pages to be grouped together. The variable is optional, and the default value is 0 (anonymous).

The callback variable is a function name to be called when the tests have been completed. This can be used to report back to the user on the results of the tests. The default value of this variable is no callback. When using callback, note that This script has a timeout of 10 seconds. This means that the script will wait for 10 seconds before reporting the test results and invoking the callback function.

An example of using these settings to perform a rudimentary callback is in the following code:

<html>
  <head>
    <title>ipv6-test</title>
</head>

  <body>
    <h1>ipv6-test</h1>

 <body bgcolor=#FFFFFF>

 <div>
    <div> IPv4: <span id='ipprototest_ok_r4td'></span> </div>
    <div> IPv6: <span id='ipprototest_ok_r6td'></span> </div>
    <div> Dual: <span id='ipprototest_ok_rdtd'></span> </div>

    <div> 6dns: <span id='ipprototest_ok_rdt6'></span> </div>
    <div> 6lit: <span id='ipprototest_ok_v6lit'></span> </div>
    <div>  stf: <span id='ipprototest_ok_v6stf'></span> </div>
    <div>  ter: <span id='ipprototest_ok_v6ter'></span> </div>

    <div> IPv4 Speed: <span id='ipprototest_speed_r4td'> </span> </div>
    <div> IPv6 Speed: <span id='ipprototest_speed_r6td'> </span> </div>
    <div> Dual Speed: <span id='ipprototest_speed_rdtd'> </span> </div>

    <div> 6dns Speed: <span id='ipprototest_speed_rdt6'> </span> </div>
    <div> 6lit Speed: <span id='ipprototest_speed_v6lit'> </span> </div>
    <div>  stf Speed: <span id='ipprototest_speed_v6stf'> </span> </div>

    <div>  ter Speed: <span id='ipprototest_speed_v6ter'> </span> </div>
 </div>

<script type="text/javascript">

  // for all possible tests, update an _ok and a _speed entry in HTML 
  function results(r) {
		  // complete test set. 
        var tests = ['r4td','r6td','rdtd','rdt6','v6lit','v6stf','v6ter'];
        for(var i=0;i<tests.length;i++) {
            var x = tests[i];
		        var innerDiv;
		        if ( innerDiv = document.getElementById('ipprototest_ok_' + x) ) {
		    if ( r[x] === false ) {
		        innerDiv.innerHTML = 'failed';
		    } else if ( r[x] ) {
		        innerDiv.innerHTML = 'OK';
		    } else {
		        innerDiv.innerHTML = 'not tested';
		    }
		        }
		        if ( innerDiv = document.getElementById('ipprototest_speed_' + x) ) {
		    if ( r[x] === false ) {
		        innerDiv.innerHTML = 'failed';
		    } else if ( r[x] ) {
		        innerDiv.innerHTML = r[x] + 'ms';
		            } else {
		        innerDiv.innerHTML = 'n/a';
		            }
		        }
		    }
  }

  // initialize google analytics
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-597837-4']);  // google analytics account
  _gaq.push(['_setDomainName', 'www.cidr-report.org']);  // domain being tracked

  (function() {
   var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 
   ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 
  })();

// enable the APNIC IPProtoTest and feed google analytics events
  if ('http:' == document.location.protocol) {

   // setting the options
   var ipproto_opts = {
     'docookies'        : false,       // test based on noCheckInterval in cookie
     'noCheckInterval'  : 86400000,    // interval to test on, if docoookies is true
     'dov6dns'          : true,        // test v6 dns to a dual-stack URL
     'dov6literal'      : true,        // test a v6 literal URL
     'dotunnels'        : true,        // test for 6to4 and teredo tunnels
     'randomize'        : true,        // by default, sorted test order
     'sampling'         : 1,           // 1/sampling eg sampling=4 1/4th tested
     'userId'           : '123456',    // what to log in the collector website 
     'callback'         : results      // prototype function to receive callback of results
   };

   (function() {
    var iga = document.createElement('script'); iga.type = 'text/javascript'; iga.async = true; 
    iga.src = 'http://labs.apnic.net/ipprototesto.js';
    var is = document.getElementsByTagName('script')[0]; is.parentNode.insertBefore(iga, is); 
   })();
  }

</script>
</body>
</html>