Thursday, December 18, 2014

Google sitespeed score - script to tap api and Alexa top 10,000

Pagespeed - Score

Even if it would not be relevant for large site indexation, it still has huge impact on traffic, bounce rate and CE. Google offers a great tool to get their feedback - the sitespeed score. It does not show the actual speed, but how your page is build compared to an page ideally built for speed. So it shows the potential to improve.

As input I use the top 10,000 from the Alexa top million pages - using the homepage, only. (I actually split it in 10, ran the script 10x in parallel). The process is relatively slow, as Google checks the pages, and give much more details back than just the score - which I filter out, below. Just fill in your api key (after the = sign) and feed your sitemap (just urls) to the script. Below is for mobile sitespeed, for desktop just swap mobile with desktop. The allowance currently is 25 k api calls a day for free, that's plenty for most sites or projects.

Mobile sitespeed score scatterplot of Alexa top 10,000 sites homepages

Then I just cleaned it out, set all garbage values to zero, and build a scatterplot.
  • Few sites at 100 sitespeed score
  • a relatively sparsely populated area between 80 and 100 
  • the bulk of sites between 40 and 80
  • scores 40 and lower being less frequent as well.

Speedtest score script:

And this is the script:
echo -e 'url\tspeed-score' > ${filename}
IFS="," ; while read -r counter line; do
score=$(curl -s  -m 30 -f --retry 1 --proto =https --proto-redir =https "${line}&strategy=mobile&key=--- your api key ---" | sed -n '/score[^,]*,/p'| sed -e 's/\"//g' -e 's/,//g' -e 's/score: //g' )
echo -e "$counter \t $line \t $score" >> ${filename}
done < $1

No comments:

Post a Comment

Bookmark and Share