There are two ways to embed Google Analytics in your Ghost Pro blog: via Code Injection or by implementing it into a theme. Even though this post is focused on the Ghost Pro platform, the principles will work for other websites too.

Get the Google Analytics tracking script

The first step for both methods, is to signup for Google Analytics at Walk through the account setup until you reach the page with the Tracking code. This page contains the script (between <script> - </script> tags) you'll need in the following steps and looks like this:

" width="750

Code Injection

For the code injection method, open the Ghost Pro administration dashboard and navigate to Settings - Code Injection.
Then paste the Google Analytics Tracking script somewhere in the 'Blog Header' section:

" width="650

Save the page. Now open a page from your website and verify in the source that the script is inserted properly. If that isn't the case, your theme may not have code injection built in properly.

Implementation into a theme

The second way to get Google Analytics for your Ghost blog, is implementing it directly into your theme.
For this to work, first find your default.hbs file. When editing the theme locally, this file will be in the root-folder of your theme. Online, you can find it in the /ghost/content/themes directory.

Place the Google Analytics tracking script inside <head>-tag, just above </head>. For the default (casper)-theme the location looks as depicted below:

" width="550

Save the file and restart Ghost or upload your theme to Ghost Pro if you edited it locally.


If, after setting up the script, you don't see any hits on your Analytics Dashboard, there are a few things that could be wrong.

Check the script

As stated above, before anything else, make sure your script is embedded correctly into the live website. Check for accidental extra characters that may have made their way into your script.

Data Processing Amendment

When I setup Google Analytics, I forgot to accept the [Data Processing Amendment] and I got no hits because of it. On the Google Analytics dashboard go to the Admin page - Account Settings. On the bottom of the page you'll find the button to accept this amendment:

" width="550

As soon as I accepted, the page views were logged and I was seeing hits in the Real-time overview.

Hopefully this information will get you going as well. Using Google Analytics will help me get more data about the demographics of my website, the popularity of my blog and use this information to fine tune its contents.

Oh, the reason I decided to blur the ID, is to prevent anybody making the mistake using my code as theirs. It's not a secret code anyways.