Do you want to know how many visitors are reading your blog posts or from which demographics your readers are from or know the age, gender and interest of your audience so that you can make adjustments to your blogs and articles? You can easily integrate 3rd Party Analytics to your blog to get this valuable insight to your blog posts.

In this How-To article I will show you two different ways to add google analytics to your blog. You can choose any 3rd party analytics of your choice, the steps will mostly be the same.

Setup Google Analytics

Most of the Ghost themes has code-injection built in using the code injection-helper so in this step I will show you how to use Code-injection to add google-analytics to your blog. This will work for any 3rd party analytics as long as they provide tracking-code to integrate with.

  • Give it a meaningful account name and select data sharing options relevant to you.
  • Select what do you want to measure, since its a blog on website so just select Web.
  • Enter your blog site details and reporting timezone and hit create
  • Copy the tracking code which you will feed to your blog settings next

Now since you have successfully setup google analytics, there are two ways you can add it to your Ghost Blog

Using Code Injection

  • Inside the admin section of your blog (yoursite.com/ghost), go to Settings -> Code Injection
  • In the header section of settings insert the tracking code you copied earlier from google analytics and save.

Directly into your theme

  • Login to your Ghost server and navigate to the Ghost themes folder (on ubuntu its /var/www/ghost/content/themes/) and go to your active theme, default theme is Casper : /var/www/ghost/content/themes/casper
  • Open defaults.hbs in your choice of editor and add the Google Analytics code inside the <head>. For Casper theme add it below {{ghost_head}} and above </head> as shown below
  • Restart Ghost (/var/www/ghost$ ghost restart)

Login to your Google Analytics and you should see some real time data and reports on your blog site.