Using Google Analytics with Ghost
Google Analytics provides detailed statistics about visitor traffic to your site. To use it with Ghost, you need a Google Analytics account and a unique Tracking ID.
Setting Up Google Analytics
-
Sign up for a Google Analytics account at Google Analytics.
-
Obtain the Tracking ID for your site.
Editing the Theme
Some Ghost themes support Google Analytics by default. If your theme does not, follow these steps:
-
Log in to Google Analytics, click Admin → Tracking Info → Tracking Code, and copy the entire tracking code, including
<script>and</script>tags. -
Using SSH, navigate to
installation_directory/content/themes/theme_name, whereinstallation_directoryis your Ghost installation folder andtheme_nameis your active theme. -
Open the default.hbs file with a text editor.
-
Paste the Google Analytics code just before the closing
</head>tag.
| Important Include both the starting <script> tag and the ending </script> tag. |
-
Save the default.hbs file.
-
Restart Ghost. Google Analytics is now enabled.
| Note It may take up to 24 hours for Google Analytics to change from Tracking Not Installed to Receiving Data. |
More Information
For further details, visit Google Analytics.