How I Added AdSense to My Website (Ghost Blog)
Adding AdSense to a Ghost blog is easy. It takes a few clicks and pasting to get it up and running. This post outlines how I introduced ads to my own Ghost blog.
In January 2022 after having my site for two years, I figured I'd try to see what the advertisement ecosystem looked like. Looking around at different providers, I went with Google's AdSense as I already had other Google products in place.
Signing Up To AdSense
Signing up is just as easy as any other website.
- https://www.google.com/adsense/start/
- Put in some numbers in the calculator
- Clicked Get Started
- Put in details
Adding Ad Code to Website
Ghost have a great tutorial on how to do this, however, I'll show these steps with my own examples on how I did it.
Connecting Site to AdSense
AdSense will give you a couple of code snippets required to get the ads started. From AdSense, grab the code and inject it to the header through Ghost. This is via Settings > Code Injection then paste it into the Header area. Mine (which also has Google Analytics) looks like:
Creating Ad Units
Ad units are each individual ad placement on your page. These give you control of where your ads will be placed and the form factor. There is another option too, Auto Ads. These ads will be placed on your page where Google deems fit. For my website, I will be using Ad Units.
To create an Ad Unit head to your AdSense home and click on the Ads side menu option, then one of the four under "Create new ad unit". For my site, I created two Display Ads where one went to the top of a post and one at the bottom.
When creating a new Ad Unit I found that generating a horizontal advertisement still gave me a square one, I had to explicitly write it out as a horizontal ad. Check out the commit for my theme below where I add the bottom ad:
Ads.txt
According to Google, ads.txt helps as:
It can help buyers identify counterfeit inventory and help you receive more advertiser spend that might have otherwise gone toward that counterfeit inventory.
More information in the two links below:
Essentially, you add this to your root, the commit for my theme is here:
Sellers.json
Seems to allow for a more transparent way for advertisers to discover ad users.
This gives advertisers a reliable way to discover and verify the identity of publishers.
See more information:
Privacy
The EU has GDPR and California has CCPA, each of these (if I skip over a lot of nuance - don't look at me I'm not a lawyer) talk about consent and data processing. AdSense allows you to automate this consent by having a dialog show. For example if I look at the GDPR dialog, I see:
You can force these dialog boxes to appear with some URL parameters outlined here:
Oh and AdSense also suggested a Privacy page, and since I don't do anything else with user data, I took a default looking template.
To Conclude
It doesn't take long at all to begin using AdSense. Some clicks, a couple of code snippets, and a text file was all I needed to start going. There is the option for automatically placed ads (Auto ads) however I opted just to have an ad only at the top and bottom of a post. Who knows, perhaps by the time you're reading that this might've changed - and it was probably easy to change too!
I hope this helped out with understanding what needed to be done, or maybe gave you a peek into what it looks like on the other side if you're considering it.