Learn how to seamlessly integrate Google Analytics with your Ghost website to track user engagement and website performance.

Integrating Google Analytics into your Ghost-powered website is an essential step for anyone looking to gain detailed insights into their website’s traffic, user behavior, and overall performance. This step-by-step guide will walk you through the process of adding Google Analytics to a Ghost website, enabling you to start collecting valuable data in no time.

Step 1: Set Up Your Google Analytics Account

Before you can integrate Google Analytics with your Ghost website, you need to have a Google Analytics account. If you haven’t set one up yet, follow these steps:

  1. Visit the Google Analytics Website: Navigate to Google Analytics and sign in with your Google account. If you don’t have a Google account, you’ll need to create one.
  2. Create a Property: Once logged in, click on the “Admin” gear icon at the bottom left, select “Create Property,” and follow the prompts. Input your website’s name, URL, and other relevant information.
  3. Acquire Your Tracking ID: After setting up your property, Google Analytics will provide you with a Tracking ID. Note this ID, as you’ll need it to link your Ghost website to Google Analytics.

Step 2: Integrate Google Analytics with Your Ghost Website

With your Google Analytics Tracking ID in hand, you’re ready to integrate it into your Ghost website. Here’s how:

Using the Ghost Admin Interface

For Ghost versions 2.x and later, adding Google Analytics is straightforward and doesn’t require direct theme modification:

  1. Access the Code Injection Area: Log into your Ghost admin panel and locate the “Code Injection” section in the settings menu.
  2. Insert Your Tracking Code: Paste the Global Site Tag (gtag.js) provided by Google Analytics into the “Site Header” section:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_TRACKING_ID"></script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'YOUR_TRACKING_ID');

Replace YOUR_TRACKING_ID with the actual Tracking ID from Google Analytics.

Editing Your Theme Directly

If you prefer or if you’re using an older version of Ghost, you can integrate Google Analytics by editing your theme:

  1. Download Your Theme: From the Ghost admin panel, navigate to “Design,” find your active theme, and click “Download.”
  2. Edit the Theme Files: Unzip the theme and open the default.hbs file in a code editor. Insert the Global Site Tag (gtag.js) script just before the closing </head> tag.
  3. Upload and Activate Your Theme: Zip your theme folder and upload it back to your Ghost site through the “Design” section. Activate your theme if necessary.

Step 3: Verify Integration

To ensure the Google Analytics tracking code is working correctly on your Ghost website:

  1. Check Real-Time Reports: Go back to your Google Analytics account and navigate to the “Real-Time” section. Seeing active users on your site means the integration is successful.
  2. Use Google Tag Assistant: This Chrome extension can help you verify that Google Analytics is properly implemented on your site.

Wrapping Up

Integrating Google Analytics with your Ghost website is a powerful way to unlock insights into your audience and how they interact with your content. By following the steps outlined in this guide, you can set up Google Analytics and begin tracking your site’s performance, helping you make informed decisions to grow your audience and enhance your website.