How to Add an ads.txt File for Google AdSense to Your Shopify Store

How to Add an ads.txt File for Google AdSense to Your Shopify Store

(adsbygoogle = window.adsbygoogle || []).push({});

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.

  1. Log in to your Google AdSense account.

  2. 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.

  3. Click the down arrow to expand the "Create an ads.txt file for [your site]" section.

  4. 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.

  1. Log in to your Shopify admin panel.

  2. Click "Settings" in the lower-left corner.

  3. Select "Files" from the settings menu.

  4. Click "Upload files" and select the ads.txt file you downloaded earlier.

  5. 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.

  1. Go to Online Store > Navigation in your Shopify admin panel.

  2. Click "View URL Redirects."

  3. Click "Create URL Redirect."

  4. In the Redirect from field, type: /ads.txt

  5. In the Redirect to field, paste the URL of the uploaded ads.txt file (copied in Step 2).

  6. 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:

  1. Open a new browser window.

  2. Type yourstore.com/ads.txt in the address bar.

  3. Press Enter.

If the page displays the contents of the ads.txt file, the setup is correct.

⚠️ Note: It may take Google AdSense up to 24 hours to recognize the file. You can check your AdSense account later to see if the issue is resolved.


Conclusion

Adding an ads.txt file to your Shopify store is straightforward with this workaround. By uploading the file to Shopify's Files section and setting up a URL redirect, you ensure your ads run without issues while maintaining compliance with AdSense policies.

If you run into any issues, double-check your redirect settings and ensure the ads.txt file is publicly accessible. Happy monetizing!

(adsbygoogle = window.adsbygoogle || []).push({});
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.