Google AdSense + Ghost

How to use Ghost and Google AdSense together

Introduce a new revenue stream to your Ghost publication with a direct Google AdSense integration that places ads on your site that are relevant to your audience

Google AdSense is a popular advertising solution for publishers who want to add additional streams of revenue to their content. It is a free platform which unlocks the ability to place customisable advertisements across your site and get paid when ads are seen or clicked.

Getting started with AdSense involves injecting code into your Ghost site, either using the code injection tool in Ghost Admin, or for more fine-grained control, in your site’s theme layer or front-end. Here’s how to get started with Google AdSense!

Sign up for Google AdSense

Head to AdSense and use a valid Google account to get signed up. Initially, you’ll have to enter some details such as a valid address so that you can get paid, your domain, and some personal details. Once you’re in, you will then be given a code snippet which you can use to get your first ads up and running.

Account activation

If this is a brand new account, it can take 24 hours or more for it to be activated once you’ve completed the initial setup:

You will need to wait for this to be done before you are able to customise your ads and build up your campaigns. Note that if you’re using Ghost(Pro) then you will need to have a custom domain in place to integrate with Google AdSense.

Tip: Once your account is setup, try using Google Ad Manager to manage your campaigns and keep track of how your ads are performing.

Grab the Auto ads code snippet

If you want to get things set up in the simplest form - you can use the Auto ads code snippet (which is provided at setup or can be found in your account):

This code is intended to be used across your site and should be placed between the <head> and </head> tags, which you can achieve in Ghost Admin via the site header code injection feature:

You can also enter your code on specific pages or posts instead using code injection within the editor:

AdSense Auto ads technology means that Google will determine the best placement for your ads and use the available inventory on your site to display them.

Display ads in specific areas of your site using Ad units

The more likely outcome is that you would like full control over the placement of your AdSense ads. There are several ways to achieve this using Ad units in AdSense.

Ad units can be created in your AdSense account and unlike Auto ads, they are designed to be used on specific pages and placed within the <body> and </body> tags. Once you have created a new Ad unit, copy and paste the code:

If you want to display ads on a specific post or page where the content exists in Ghost Admin, it’s possible to use an HTML card within the editor to display ad blocks in-line with your content:

On the other hand, you can also insert your AdSense code into the appropriate template files within your theme. This is useful if you want to specify exactly where ads appear within your site’s content. Common places include at the top or bottom of the page, and in the sidebar.

Locate the template file where you want to insert ad unit code. It’s usually post.hbs - right after the content. In Ghost’s official themes, add code right after the line that reads {{content}}.

Add custom content to a Ghost theme

After editing, save the file, upload a fresh copy of your theme, and (if you’re self-hosting) restart Ghost.

Alternatively, you can insert your Ad units code in any area within a Handlebars theme template file, or in a custom front-end.

Implement your AdSense code

Whether you’re using Auto ads where Google AdSense decides where to display the ads, or Ad units where you determine where your ads appear, once you’ve implemented your code in any of the ways shown above, you’ll start to see the ads appearing within a couple of hours.

All ad customisation, such as determining which ads are shown or to apply other advanced features such as Custom Search Ads, can be done within the AdSense dashboard. Find out more about how to customise your ads using the AdSense help resource.