title: Implementing Google Adsense inside a p(react) project using javascript
body: <p>I have an issue and I've spent A LOT OF TIME trying to solve this. I am trying to add the Google Adsense code to my Preact project which works the same as React. My status stays stuck at: &quot;<strong>Your site needs work</strong>&quot;. the additional information explains that Google can't find the code. Even though I've added it (in multiple ways).</p>
  <p>What I've found out is that every time this line:</p>
  <pre><code>&lt;script data-ad-client=&quot;ca-pub-#####&quot; async src=&quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js&quot;&gt;&lt;/script&gt;
  </code></pre>
  <p>gets transformed to this line:</p>
  <pre><code>&lt;script data-ad-client=&quot;ca-pub-#####&quot; async=&quot;&quot; src=&quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js&quot; data-checked-head=&quot;true&quot;&gt;&lt;/script&gt;
  </code></pre>
  <p>This is how I'm trying to add the code:</p>
  <p><strong>Option 1: In my app.js file</strong></p>
  <pre><code>componentDidMount() {
          //SetAdsense
          let script = document.createElement('script');
          script.setAttribute('data-ad-client','ca-pub-########' );
          script.setAttribute('async');
          script.src = &quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js&quot;;           
          document.getElementsByTagName('head')[0].appendChild(script);
  }
  </code></pre>
  <p><strong>Option 2: Using Helmet</strong></p>
  <pre><code>&lt;Helmet&gt;
     &lt;script data-ad-client=&quot;ca-pub-#####&quot; async src=&quot;https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js&quot;&gt;&lt;/script&gt;
  &lt;/Helmet&gt;
  </code></pre>
  <p>Any idea how I can make Google see the provided Adsense code in my Head?</p>
  <p><em><strong>UPDATE 1 23/07/2020</strong></em>
  I've just found out that the reason for not getting Adsense implemented is not related to the way I've implemented the Adsense code snippet. 2 reasons for this assumption:</p>
  <pre><code>Adsense has unapproved my website with the message: No content provided (which is strange because I've tested the crawlresults in the Google Webmaster tools and it crawls my website like a charm).
  This solution has the same changes in the snippet and the Ads are still working.
  https://react-adsense.xmplaylist.com/
  </code></pre>
  <p>So my issues could be related to Preact (or the usage of any JS framework). I cant figure out why exatly yet, because I prerender al my pages (using the json file) and running the <code>preact build</code> should automatically use that json to prerender all these pages right?</p>
  <p>My prerender-urls.json looks like this:</p>
  <pre><code>[{  
      &quot;url&quot;: &quot;/&quot;,
      &quot;title&quot;: &quot;Homepage&quot;
    },
    {  
      &quot;url&quot;: &quot;/error&quot;,
      &quot;title&quot;: &quot;ErrorPage&quot;
    },
    {  
      &quot;url&quot;: &quot;/other&quot;,
      &quot;title&quot;: &quot;Other&quot;
    }
   etc.etc.etc.
  </code></pre>
  <p><strong>UPDATE 2 24/7/2020</strong></p>
  <p>If I open a random page&gt;index.html it looks like this  (see screenshot) in Chrome. I'm shure thats why Google Adsense request gets disaproved.How can I prerender the pages WITH the content rendered as well? All static content is visible in the screenshot.All dynamic content comes from a JSON file which gets loaded by javascript. I use the URL as the key to determine which content should be displayed.
  <a href="https://i.stack.imgur.com/5kb1A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5kb1A.png" alt="enter image description here" /></a></p>
  <p>Kind regards!</p>