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
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:
- 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.
- 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.
- Use your preferred text editor to open the default.hbs file.
- 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.
- Save your changes to the default.hbs file.
- 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.
For more information about Google Analytics, please visit http://www.google.com/analytics.