How to use Google Analytics with Ghost

This article discusses how to use Google Analytics with a Ghost site.

Using Google Analytics with Ghost

Google Analytics provides detailed statistics about visitor traffic to your site. To use Google Analytics with Ghost (or with any other type of site), you must first sign up for a Google Analytics account at http://www.google.com/analytics and obtain a unique Tracking ID.

After you have set up a Google Analytics account and have the Tracking ID for your site, you can configure it for Ghost. To do this, you add some code to the Ghost theme you are using.

Editing the theme

You can edit the Ghost theme directly to enable Google Analytics. By embedding a Google Analytics JavaScript code snippet in the theme, you can make sure that statistics gathering is enabled for every page.

Some Ghost themes include Google Analytics support by default. If you are not using the default theme, consult your theme's documentation.

To enable Google Analytics in a Ghost theme, follow these steps:

  1. Log in to your Google Analytics account, click Admin, click Tracking Info, and then click Tracking Code. Copy the entire text in the tracking code box, including the starting <script> tag and the ending </script> tag.
  2. Using SSH, navigate to the installation_directory/content/themes/theme_name directory, where installation_directory is the directory where Ghost is installed and theme_name represents the theme currently enabled for your site.
  3. Use your preferred text editor to open the default.hbs file.
  4. Paste the Tracking ID code snippet from Google Analytics that you obtained in step 1 just before the closing </head> element.
    Make sure you include the starting <script> tag and the ending </script> tag.
  5. Save your changes to the default.hbs file.
  6. Restart Ghost. Google Analytics is now enabled.
    It can take up to 24 hours for Google Analytics to change its status from Tracking Not Installed to Receiving Data.

More Information

For more information about Google Analytics, please visit http://www.google.com/analytics.

Get Ghost Hosting

Article Details

  • Product: All unmanaged hosting accounts
  • Level: Intermediate

Related Articles

Show More

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.