Graesen Arnoff

View Original

How to Get Google Adsense to Work on Squarespace

If you find this helpful, please help support my site and my work by either donating with the button below or by ordering a print of your favorite photo from my shop.

See this content in the original post

Update 3/16/2020

New guide published. All steps below are not relevant anymore, but I am keeping them here as a reference and to use as a resource if it was helpful to anyone.

Updated guide is here: www.graesen.com/blog/resolve-google-adsense-your-earnings-may-be-at-risk-error-for-squarespace

When I switched from traditional web hosting to Squarespace, I was surprised to find there wasn’t documentation for adding Google Adsense ads to your website. In fact, when I searched for a solution, I found very few answers. The answers I did find required you to use a third-party site to act as a middleman or to use Squarespace’s developer mode (which has its own drawbacks). Borrowing a lot of the steps required a middleman site, I will explain how to ensure Google Adsense works on your Squarespace site without any third-parties.

The Problem

I’m an old school web guy. I’m used to writing code, managing my own files, designing my own graphics, etc. You can imagine some of the struggle in giving up some of that control when I switched to Squarespace. When I finished building my site with a provided template, I decided to begin placing my ads from Google Adsense. These ads only exist on the blog and are a means of helping me cover the costs of running my site.

Placing the ads was no problem. The issue was Google Adsense requires a file called ads.txt to exist at the root level of your site for ads to work properly. There is no file manager or FTP service with Squarespace. This I didn’t realize beforehand. Instead, files are uploaded to a default directory in which the customer has no control over. So when you do upload your ads.txt file, it goes wherever Squarespace decides it should go, not the root level of the website where Google expects it to be.

The Solution

Don’t worry, I’ll lay out the steps below but I want to explain the process first. When I looked for a solution, I found at least two websites advising you to upload the ads.txt file to their website and use a URL redirect to trick Google into thinking the file is in the root level. That’s fine and everything, but I don’t trust third-parties very much. What if they go out of business? What are they really doing with my file? What if I move companies to run my website and forget a third-party has this file? Keep in mind that the ads.txt file contains your Google Adsense publisher ID number. I don’t know if that can be exploited, but I don’t want to risk that possibility.

If the ads.txt file can exist on a completely different website and you can use a URL redirect to trick Google into thinking the file is where it needs to be, why can’t I do the same thing on my existing site? You can upload files of virtually any type on your Squarespace site as long as it’s under 20 MB in file size. Uploading a text file would be no different. The trickier part is getting the exact address of the file after it’s uploaded. You need this to get the redirect to work properly. Once you put these pieces together, you can copy/paste your Google Adsense ad codes onto your site without worry. If you use Google’s new Auto Ads feature, you will have to use code injection which is not available on the cheapest Squarespace plan.

Photographer Aaron Andino was kind enough to produce a great quality video walking you through the following steps. He continues to show you how to add ads to your sidebar as well, which I didn’t cover. If you prefer to watch step-by-step rather than reading, go ahead in click play and give Aaron a like.

Steps:

  1. Create your ads.txt file if necessary (see Google Adsense for more information)

  2. Upload the ads.txt file by following Squarespace’s upload steps here

  3. Add the ads.txt file to a page (this will only be temporary)

  4. View the page with the ads.txt file

  5. Right click the file and choose “copy link address” (the exact words may be different depending on the browser you are using)

  6. Paste the link address somewhere for safe keeping (notepad, Word, email, etc.) — you’ll need this address for the redirect steps

  7. Setup a URL redirect following Squarespace’s steps here

  8. The code for the URL redirect should resemble the following:

    /ads.txt -> /[the copied link address] 301

    or

    /ads.txt -> /https://graesen.com/s/ads.txt 301

  9. Remove the “/https://[yoursite.com]” from code

    /ads.txt -> /s/ads.txt 301

  10. Type “[yoursite.com]/ads.txt” into the address bar of your browser to verify it works. You should see the ads.txt file start to download if you did this correctly. If it does not download, you missed a step or mistyped the URL redirect code.

  11. Delete the text/link to the ads.txt file from Step 3 (DO NOT delete the file, only the reference to the file)

Now you can insert the ads for Google Adsense wherever you want on your Squarespace site. You still need to log into Google Adsense and create your ads. Then copy the code for an ad and place it in your website. Please note that ads may not appear immediately and your browser cache can affect how or if you see them at all.