M
Martin AJ
Guest
I've followed the below steps for adding AdSense script inside of my website:
I did it and all fine. Here is my full code: (define as a tag in google tag manager)
Script above will be added to the dom separately. I mean, this part:
appends to the
appends to the
Any idea how can I make GTM force to add both scripts right after each other inside
<p>I've followed the below steps for adding AdSense script inside of my website:</p>
<ol>
<li>Now that you have the code head over to GTM.</li>
<li>Create a new tag.</li>
<li>Provide a name.</li>
<li>Select custom HTML as the tag template.</li>
<li>Copy and paste the code into the text field.</li>
<li>Set the trigger to fire on All pages or the pages you want to serve ads on.</li>
<li>Click Save and Submit to push the code live.</li>
</ol>
<p>I did it and all fine. Here is my full code: (define as a tag in google tag manager)</p>
<pre><code><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-<token>",
enable_page_level_ads: true
});
</script>
</code></pre>
<h2>The problem is:</h2>
<p>Script above will be added to the dom separately. I mean, this part:</p>
<pre><code><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
</code></pre>
<p>appends to the <code><head></code> section, and this part:</p>
<pre><code><script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-<token>",
enable_page_level_ads: true
});
</script>
</code></pre>
<p>appends to the <code><body></code> section. So Google AdSense says:</p>
<blockquote>
<p>The code is missing or incomplete</p>
</blockquote>
<p>Any idea how can I make GTM force to add both scripts right after each other inside <code><head></code> section?</p>
Continue reading...
- Now that you have the code head over to GTM.
- Create a new tag.
- Provide a name.
- Select custom HTML as the tag template.
- Copy and paste the code into the text field.
- Set the trigger to fire on All pages or the pages you want to serve ads on.
- Click Save and Submit to push the code live.
I did it and all fine. Here is my full code: (define as a tag in google tag manager)
Code:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-<token>",
enable_page_level_ads: true
});
</script>
The problem is:
Script above will be added to the dom separately. I mean, this part:
Code:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
appends to the
<head>
section, and this part:
Code:
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-<token>",
enable_page_level_ads: true
});
</script>
appends to the
<body>
section. So Google AdSense says:The code is missing or incomplete
Any idea how can I make GTM force to add both scripts right after each other inside
<head>
section?<p>I've followed the below steps for adding AdSense script inside of my website:</p>
<ol>
<li>Now that you have the code head over to GTM.</li>
<li>Create a new tag.</li>
<li>Provide a name.</li>
<li>Select custom HTML as the tag template.</li>
<li>Copy and paste the code into the text field.</li>
<li>Set the trigger to fire on All pages or the pages you want to serve ads on.</li>
<li>Click Save and Submit to push the code live.</li>
</ol>
<p>I did it and all fine. Here is my full code: (define as a tag in google tag manager)</p>
<pre><code><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-<token>",
enable_page_level_ads: true
});
</script>
</code></pre>
<h2>The problem is:</h2>
<p>Script above will be added to the dom separately. I mean, this part:</p>
<pre><code><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
</code></pre>
<p>appends to the <code><head></code> section, and this part:</p>
<pre><code><script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-<token>",
enable_page_level_ads: true
});
</script>
</code></pre>
<p>appends to the <code><body></code> section. So Google AdSense says:</p>
<blockquote>
<p>The code is missing or incomplete</p>
</blockquote>
<p>Any idea how can I make GTM force to add both scripts right after each other inside <code><head></code> section?</p>
Continue reading...