How to Add Google Analytics to Ghost

There are two ways to add Google Analytics to Ghost. One is using the built in code injection, and the other is to add it directly to your theme. Code injection is something that a theme has to have integrated using the code injection helpers, but most themes should. We cover using both code injection and inserting the code directly into the theme in this post.

Using Code Injection

  1. Get your Google Analytics tracking code from
  2. Inside the admin section of your blog (, go to Settings -> Code Injection

    Google Analytics

  3. In the header section of code injection, insert your tracking code

    Google Analytics

  4. Click on save. Now, as long as your theme has code injection built in (most should), your code will now show up in your header and your done!

Directly into Theme

  1. Get your Google Analytics tracking code from
  2. Inside your Ghost folder, you will see a content folder. Open up that folder and then open up the themes folder inside of it. If you are using the command line, this is the path:

  3. Inside this themes folder, open up the default.hbs file in a text editor.

  4. You want to add the Google Analytics code inside the <head>. For the Casper theme, we want to add it just below the {{ghost_head}} and above </head>.
    Ghost Google Analytics
  5. Restart Ghost

Once Ghost has been restarted, your Google Analytics code should now be up and running. If you edited the theme locally, you will need to upload the theme to Ghost(Pro) or whatever hosting you are using before you restart Ghost.

Head to our next section to learn how to add Disqus comments to your Ghost blog!

Add Disqus Comments