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.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
2014-02-20 12:16 pm
Thanks for the tips. I'd suggest, although, inserting the script at the end of the page as stated on browser diet http://browserdiet.com/#css-on-top-js-on-bottom
Staff
9,162 Points
2014-02-20 1:05 pm
Typically, you would want to place most JavaScript futher down the page, but with Google Analytics, it is recommended by Google to place it within your header for more accurate tracking, as well as it is asynchonous so placing it higher in your code will not affect the loading of other elements even if it is closer to the top.
2014-02-20 1:20 pm
Thanks for the reply JeffMa. Didn't know it was a recommendation by Google. Will surely consider that.
n/a Points
2014-03-07 2:07 pm

Thanks Jeff.  Just got started on ghost and this helped check a task off my list.

 

Cheers!

n/a Points
2014-03-12 8:00 pm

All, I've put the tracking in default.hbs and can see it reflected in the page source. Still Google Analytics is telling me tracking is not installed. Does anyone have any tips at this point? Thanks.

FYI - Using the Amazon Ghost AMI on an EC2

Staff
9,162 Points
2014-03-14 8:30 am
If you're seeing it in the source, it should be all set. I have seen Google Analytics take a few visits to your site before it is reporting correctly so that could be a possibility. As long as the tracking code is visible in the source between the opening and closing <head> tags, everything is in place correctly and Google may just be lagging behind in fully detecting the tracking code.
n/a Points
2014-03-14 12:45 pm

@jeffMa - thanks for the help! you're right. just had to wait a few days and it showed up. 

n/a Points
2014-08-14 2:55 pm

If  you're using CloudFlare as your CDN, no need to modify files. Instead, there's an app for that: http://www.habdas.org/add-google-analytics-ghost-cloudflare/

Staff
9,684 Points
2014-08-14 3:07 pm
Hello Josh,

Thank you for your suggestion about using Cloudflare CDN services with Ghost. If you want to create a post about your app in our User Submitted section, I would be happy to link your comment to it.

If you have any further questions, feel free to post them below.
Thank you,

-John-Paul

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

9 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!