Adding Google Analytics to Ghost
In this article, we will walk you through the process of manually adding Google Analytics to your website built with Ghost. Unfortunately, at the time of writing this Ghost does not have a plugin or specific setting to integrate Google Analytics to your site, but the process is still fairly straightforward due to the simplicty of Ghost themes.
Adding a new site to Google Analytics for Ghost to use
If this is the first time that you are setting this site up with Google Analytics, you will need to first create a new site within Google Analytics. To do so, log into your Google Analytics account, then click on Admin. The left side section will have a dropdown box. Click on that, then click on "Create new account".
Next, simply enter in your information for your site such as a name for it, the URL, category, and time zone.
After you have created the new account, you will be provided a tracking code. Be sure tyo keep this in a easy to remember place as you will be using it for the next steps.
Inserting your Google Analytics tracking code into Ghost
Although we do not yet have a solution available to place Google Analytics within a site made with Ghost directly through the admin dashboard, it can be inserted just as easily within your Ghost theme.
First, you will need to locate a file that is used on every page within your Ghost theme. In this example, we are using the default Casper theme in which we can easily insert it into the default.hbs file. Any themes will be located in their respctive folders inside the /content/themes folder.
From here, locate your default.hbs file and open it. In here, you will see some familiar HTML tags. Then, locate the </head> tag. Once you have found this HTML tag, simply place your Google Analytics code directly above it. Once it is in there, save your file and restart Ghost. You should now see your data being successfully tracked by Google Analytics.
Thank you for your feedback!