Adding Disqus and Google Analytics to Ghost blog

When I started blogging with Ghost, the first changes I made were adding Google Analytics to the blog and Disqus to each post.

git clone https://github.com/TryGhost/Casper  

Adding Google Analytics

Edit Casper-1.0.0/default.hbs and add the following code (remember to update the Google Analytics identifier) just above < /head>.

    <script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-00000000-1', 'auto');
  ga('send', 'pageview');
    </script>

Adding Disqus to posts

Edit Casper-1.0.0/post.hbs and add the next code just below the {{/post}} tag.

    <div id="disqus_thread"></div>
    <script type="text/javascript">
      (function() {
       var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
       dsq.src = 'http://dutchcoders.disqus.com/embed.js';
       (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
      })();
    </script>

Now you can zip the complete theme, and upload it using 'Upload a new theme' button in the ghost site management. When you click the 'Save all blog settings' button, the new theme will be applied.

zip -r casper.zip Casper-1.0.0/*