2

I want to use the Google Adsense Auto-Ads with my react application. The react application uses SSR and I have added the code that Google provided me to the head section of the template as shown below.

export default ({ markup, css }) => {
  return `<!doctype html>
      <html lang="en">
        <head>
          <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9999999999999999" crossorigin="anonymous"></script>
          <meta charset="utf-8">
          <meta
            name="viewport"
            content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no"
          >
          <title>Teach Learn Game</title>
          <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400">
          <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
          <style>
              a{
                text-decoration: none;
                color: #bb4d00
              }
          </style>
        </head>
        <body style="margin:0">
          <div id="root">${markup}</div>
          <style id="jss-server-side">${css}</style>
          <script type="text/javascript" src="/dist/bundle.js"></script>          
        </body>
      </html>`;
};

When at the site, I have checked the html code using Chrome tools. I can see the line in the code but unfortunately I have been declined by the Google Adsense review saying I need to Fix some things.

The message from Google specifying the issue is: We couldn’t find the code on your site. This is because the code is either missing or incomplete, or because the URL of your site is incorrect. Learn more.

I have removed the requirement to login which was an earlier problem and I have a proper google account.

I did see another Stack Overflow issue where it was stated that window.adsbygoogle is to be used with React but it seemed that the problem was dealing more with specifying ad units and the implementation of the window.adsbygoogle was in a component class. As I am using Auto Ads I would not expect that would apply but maybe I am mistaken. If so, how would I change the code?

In any case, appreciate if anyone with experience with getting initial acceptance for Google Auto Ads can assist. If you provide code appreciate if you could use functional components as I am not very up on class components and the use of componentDidMount as most of the examples seem to be using.

Link to my site: https://tlgamer.herokuapp.com/

j-terranova
  • 539
  • 1
  • 10
  • 23

1 Answers1

1

Adsense will look for Adcode in herokuapp.com instead of tlgamer.herokuapp.com that is why message from Google was "We couldn’t find the code on your site.", You can not monetize a subdomain if you do not own the main domain. Switch your SSR app to a top-level domain and re-apply for Adsense.

Niresh
  • 611
  • 5
  • 16
  • Just to be sure I understand, I have created a domain with Network Solutions called www.tlgamer.com. I have not yet connected to the heroku application as I thought it would be easier to get the application approval first. Sounds like I was incorrect in that assumption. Can you confirm that, all I need to do is connect my tlgamer.com domain to the heroku app and then use the tlgamer.com domain when applying for adsense? – j-terranova Sep 12 '21 at 21:53
  • Yes i am sure. But Google might approve or reject your website depending on your quality of your site and traffic. – Niresh Sep 14 '21 at 18:38
  • 1
    I was hoping to confirm that it works before checking the box. Unfortunately my domain provider set it up incorrectly (with a two day turnaround I am losing 4 days total) and it is taking longer that I expected. As it could be 3 or 4 more days before I am able to work through the changes and approvals, I will check the box and get back to you if it does not solve the issue... understanding that there could be other reasons that Google does not approve. Thanks for your assistance. – j-terranova Sep 15 '21 at 23:29
  • Yes there could be other reasons for Google not accepting your domain into Adsense, but the answer i mentioned above is the reason for "We couldn’t find the code on your site." – Niresh Sep 16 '21 at 06:29