Last active
August 29, 2015 13:56
-
-
Save robflaherty/9144393 to your computer and use it in GitHub Desktop.
This shows the percentage comparison between two advanced segments on the Overview dashboard
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
(function() { | |
var el=document.createElement('div'), | |
b=document.getElementsByTagName('body')[0]; | |
// more or less stolen form jquery core and adapted by paul irish | |
function getScript(url,success) { | |
var script=document.createElement('script'); | |
script.src=url; | |
var head=document.getElementsByTagName('head')[0], | |
done=false; | |
// Attach handlers for all browsers | |
script.onload=script.onreadystatechange = function(){ | |
if ( !done && (!this.readyState | |
|| this.readyState == 'loaded' | |
|| this.readyState == 'complete') ) { | |
done=true; | |
success(); | |
script.onload = script.onreadystatechange = null; | |
head.removeChild(script); | |
} | |
}; | |
head.appendChild(script); | |
} | |
getScript('//code.jquery.com/jquery.min.js', function() { | |
$jq = jQuery.noConflict(); | |
// This is the part that does the GA stuff | |
$jq('._GAgL').on('click', function(e) { | |
var $e = $jq(e.target); | |
var a = $e.text(); | |
var b = $e.parents('._GAZt').next('._GAZt').find('._GAgL').text(); | |
var res = Math.round(parseInt(a, 10) / parseInt(b, 10) * 100) + '%'; | |
$e.append('<small style="color: #666"> ' + res + '</small>') | |
}); | |
}); | |
})(); |
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
javascript:(function(){var%20el=document.createElement('div'),b=document.getElementsByTagName('body')[0];function%20getScript(url,success){var%20script=document.createElement('script');script.src=url;var%20head=document.getElementsByTagName('head')[0],done=false;script.onload=script.onreadystatechange=function(){if(!done%20%26%26(!this.readyState||%20this.readyState=='loaded'||%20this.readyState=='complete')){done=true;success();script.onload=script.onreadystatechange=null;head.removeChild(script);}};head.appendChild(script);}getScript('//code.jquery.com/jquery.min.js',function(){$jq=jQuery.noConflict();$jq('._GAgL').on('click',function(e){var%20$e=$jq(e.target);var%20a=$e.text();var%20b=$e.parents('._GAZt').next('._GAZt').find('._GAgL').text();var%20res=Math.round(parseInt(a,10)/%20parseInt(b,10)*100)+'%25';$e.append('%3Csmall%20style=%22color:%23666%22%3E%20'+res+'%3C/small%3E')});});})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like this:
https://dl.dropboxusercontent.com/u/1125125/ga-percents.gif