Knowledge Base

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 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 or the cPanel File Manager, navigate to the ~/public_html/content/themes/theme_name directory, where 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