Created
November 1, 2012 14:26
-
-
Save collegeman/3993934 to your computer and use it in GitHub Desktop.
Get a list of individual organic search keywords, sorted by frequency, from the Google Analytics UI
This file contains hidden or 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
// step 1: Open Google Analytics to Traffic Sources => Sources => Search => Organic | |
// step 2: Change "Show rows" field to 500 | |
// step 3: Open the JS console, and run the following script | |
var s = document.createElement('script'); s.src = '//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js'; document.getElementsByTagName('body')[0].appendChild(s); | |
var text = jQuery('td.sf span').map(function(i, el) { return jQuery(el).text(); }); | |
// step 4: Then run this one: | |
var words = {}; | |
for (var i=0; i<text.length; i++) { | |
var w = text[i].split(' '); | |
for (var wi=0; wi<w.length; wi++) { | |
if (!words[w[wi]]) words[w[wi]] = 0; | |
words[w[wi]]++; | |
} | |
} | |
var sorted = []; | |
for (var keyword in words) sorted.push([ keyword, words[keyword] ]); | |
sorted.sort(function(a, b) { return b[1] - a[1]; }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment