/ tech-note

Add Google Analytics and Adsense into your Ghost blog

The answer is simple enough to add your script to theme files🙊

Google Adsense
  1. Create an ad partial like ad-banner.hbs template and copy/paste your ad script to the file.

  2. Edit the relevant files (e.g. index.hbs, post.hbs, etc...) to insert the ad partials.

Google Analytics

To add Google Analytics, not only you can insert the script to your theme files but also use the built-in code injection in Ghost.

To use the code injection:

  1. Check if your theme supports the code injection (most themes do).

  2. Go to Admin page of your blog and go to Settings | Code Injection.

  3. Insert your script in the header section of code injection.

To insert directly into the themes, follow the same steps as the Adsense, but since this is a tracking script, you shall be able to insert your script to the default.hbs without creating a separate partial.