
How to Add an ads.txt File for Google AdSense to Your Shopify Store
Share
(adsbygoogle = window.adsbygoogle || []).push({});
📌 Example: The uploaded file's URL might look like this:
Now that your file is hosted in Shopify, you need to create a redirect so that it can be accessed from
Now, when someone (or Google AdSense) visits
If you’re using Google AdSense on your Shopify store, adding an ads.txt file is essential. This file helps prevent unauthorized ad sellers, ensuring that only approved sources display ads on your site. Since Shopify doesn’t provide direct access to your root directory, the solution is to upload the file to Shopify's "Files" section and create a redirect.
Follow this step-by-step guide to set up your ads.txt file correctly.
Step 1: Download the ads.txt File from Google AdSense
Before adding the file to Shopify, you need to obtain it from your AdSense account.
-
Log in to your Google AdSense account.
-
Look for any alerts on your homepage. If there’s a warning about missing ads.txt, click "Fix now." Alternatively, go to the Sites tab.
-
Click the down arrow to expand the "Create an ads.txt file for [your site]" section.
-
Click "Download" to save the ads.txt file to your computer.
This file contains important authorization details for your ads, so do not edit its contents.
Step 2: Upload the ads.txt File to Shopify
Since Shopify doesn’t allow direct file placement in the root directory, you’ll need to upload it to Shopify’s Files section.
-
Log in to your Shopify admin panel.
-
Click "Settings" in the lower-left corner.
-
Select "Files" from the settings menu.
-
Click "Upload files" and select the ads.txt file you downloaded earlier.
-
Once uploaded, copy the URL of the file. This will be used in the next step.
📌 Example: The uploaded file's URL might look like this:
https://your-shopify-store.myshopify.com/cdn/shop/files/ads.txt
Step 3: Create a Redirect to the ads.txt File
Now that your file is hosted in Shopify, you need to create a redirect so that it can be accessed from yourstore.com/ads.txt
, as required by Google AdSense.
-
Go to Online Store > Navigation in your Shopify admin panel.
-
Click "View URL Redirects."
-
Click "Create URL Redirect."
-
In the Redirect from field, type:
/ads.txt
-
In the Redirect to field, paste the URL of the uploaded ads.txt file (copied in Step 2).
-
Click "Save redirect."
Now, when someone (or Google AdSense) visits yourstore.com/ads.txt
, they will be redirected to the correct file location.
Step 4: Verify Your ads.txt Setup
After setting up the redirect, confirm that your ads.txt file is accessible:
-
Open a new browser window.
-
Type
yourstore.com/ads.txt
in the address bar. -
Press Enter.