How to force GTM to add tag in the <head>?
10:46 21 Jul 2019

I've followed the below steps for adding AdSense script inside of my website:

  1. Now that you have the code head over to GTM.
  2. Create a new tag.
  3. Provide a name.
  4. Select custom HTML as the tag template.
  5. Copy and paste the code into the text field.
  6. Set the trigger to fire on All pages or the pages you want to serve ads on.
  7. 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)



The problem is:

Script above will be added to the dom separately. I mean, this part:


appends to the section, and this part:


appends to the 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 section?

javascript html google-tag-manager adsense