[Google Adsense] ads.txt を設定する

少し前から Google Adsense のトップに “Earnings at risk – One or more of your sites does not have an ads.txt file. Fix this now to avoid a severe impact on your revenue.” というような警告が出るようになった。どうやら ads.txt ファイルというのを用意してサイトにアップロードする必要があるみたい。

やり方は公式ヘルプページにサイトに従った。

ads.txt で認定販売者を宣言する – AdSense ヘルプ
https://support.google.com/adsense/answer/7532444

すなわち以下の文字列のみのテキストファイル(ads.txt)を作成する。pub-… は Google Adsense の「Account > Account information」等で確認できる。テキストファイルは utf-8 with DOM で保存する必要があるらしい。

google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0

アップする場所はルートドメイン。本ブログは blog.withachristianwife.com だが、ルートドメインの withachristianwife.com にアップする。

また http だけでなく https も両方からアクセスできるようにする必要があるみたい。もともと htaccess で http を全部 https に転送する設定にしていたが、以下のページを参考に txt のみ除外するようにした。

【.htaccess】httpアクセスをhttpsに強制リダイレクトで、特定のファイルやディレクトリを除外する方法 | MeteoricStream
https://meteoricstream.com/tips_detail/59.html

その上で、ブラウザで実際にアップしたファイルに、http および https でアクセスできることを確認する。

何時間かすると Google Adsense にアクセスしたら警告の表示がなくなった。

参考:
アドセンスでads.txtファイルの警告が表示された場合の対処方法 | iscle [イズクル]
https://www.iscle.com/web-it/g-drive/adsense/ads-txt-keikoku.html

Ensure that your ads.txt files can be crawled – AdSense Help
https://support.google.com/adsense/answer/7679060