Using Google Analytics with Ghost
Learn how to use Google Analytics with your Ghost site to get statistics about visitor traffic. Just follow our easy step-by-step guide.
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.
Note
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 tag and the ending 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 element.
Important
Make sure you include the starting tag and the ending tag.
-
Save your changes to the default.hbs file.
-
Restart Ghost. Google Analytics is now enabled.
Note
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.
Updated about 9 hours ago