function focusedSection() {
  var pos = $(document).scrollTop() + $(window).height()/2;
  var sections = $('section')
  for(var i = 0; i<sections.length; i++) {
    if(sections[i].offsetTop > pos) {
      return sections[Math.max(i-1, 0)];
    }
  }
  return sections.last()[0];
}

function updateSelected() {
  var hash = window.location.hash.substring(1)
  if(hash) { $('body').attr('data-selected', hash); }
}

function setSelected(section) {
  var selected = $('body').attr('data-selected');
  if(selected != section) {
    history.replaceState(undefined, undefined, "#" + section);
  }
  $('body').attr('data-selected', section);
}

$(document).ready(function() {
  $('nav a').click(function() { 
    setSelected($(this).attr('href').substring(1)); 
    return false;
  });

  $(window).scroll(function() {
    if($(document).width() <= 960) {
      setSelected(focusedSection().id);
    }
  });

  $(window).on('hashchange', updateSelected);
});
@@ -1,16 +1,419 @@
+// Google Analytics%0A(function(i,s,o,g,r,a,m)%7Bi%5B'GoogleAnalyticsObject'%5D=r;i%5Br%5D=i%5Br%5D%7C%7Cfunction()%7B%0A(i%5Br%5D.q=i%5Br%5D.q%7C%7C%5B%5D).push(arguments)%7D,i%5Br%5D.l=1*new Date();a=s.createElement(o),%0Am=s.getElementsByTagName(o)%5B0%5D;a.async=1;a.src=g;m.parentNode.insertBefore(a,m)%0A%7D)(window,document,'script','https://www.google-analytics.com/analytics.js','ga');%0Aga('create', 'UA-25043089-1', 'auto');%0Aga('send', 'pageview');%0A%0A
 function focused
@@ -1031,16 +1031,51 @@
 ction);%0A
+  ga('send', 'pageview', section);%0A
 %7D%0A%0A$(doc
@@ -1379,11 +1379,12 @@
 ected);%0A
-
 %7D);
+%0A

Enable google analytics