LOG IN OR SIGN UP
Log in to your account
Sign up

How To Install Adsense With Google Tag Manager

30 July 2018 | 0 comments | Posted by Che Kohler in nichemarket Advice

Installing Adsense with GTM

Running a website can be a rewarding past time, be it professionally or as a hobby. The internet gives anyone with a site and a voice the opportunity to create a business and earn money for their online efforts. One obvious way of monetizing your website is through selling ad placements on your site. Google has made it pretty easy to sell ad space with its Adsense platform but setting it up isn't always easy.

We've heard plenty of moaning on the internet since AdSense Will Discontinued it's official WordPress Plugin. Publishers were faced with a few options either hard code ad placements into your page template, which you would have to do with other CMS's, Go all in on Ads with running Double Click placements which can be pretty complex or look for third-party plugins and tools that are able to do the job.

There is, however, another way to install Adsense on your website via Google Tag Manager, if you're familiar with the tool, it shouldn't be too hard for you to pull off, it not there is a bit of a learning curve involved.

Disclaimer

Note: Before we begin, I DO NOT recommend this installation method or any method of using Jquery inject ads into a page. The embedding jQuery along with with your ad slows down your website load speed, and it also has the potential to cause hard-to-track JavaScript conflicts on your site.

Instead, use native DOM methods to add dynamic ads into your website. So perhaps use it on a test site or just as an experiment before you go all in on ad placements on your site.

How to run Adsense via GTM

In order to run Adsense on your website, you will need to run the universal ad code first and then begin marking out your ad placements on your site. At the moment Tag Manager does not support AdSense natively, but we can add a “Custom HTML Tag.”

We use this tag to he adv code with jquery (you don’t need to install jquery in your site since tag manager integrates a limited version of the library).

Adding your auto ad placement code

Auto ads use machine learning to make smart ad placement decisions on your behalf. This lets you add one piece of code just once to your pages. Let Google take care of the rest. If you're planning on running auto ads on your site via GTM here's how to do it.

Creating the ad code

  • Head over to your Adsense account
  • Under My Ads Click Content
  • Then Click on Auto Ads
  • Select the type of Ads you want to display
  • Get the universal code

Creating the ad tag

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

Note: If you're running an AMP site for mobile you will need to repeat the process under Auto Ads for AMP. You will not be able to use GTM on AMP templates this will need to be hard-coded into your page templates

Creating the ad code

  • Head over to your Adsense account
  • Under My Ads Click Content
  • Then Click on Ads units
  • Create a new ad unit
  • Give the ad unit a name
  • Then click get the code
  • Copy the specific ad code

Adding your ad placement code

  • Now head over to GTM
  • Click on variables on the left side of the screen within your GTM workspace
  • Create a new user-defined variable and call it asClientID
  • Configure the variable as a Constant. The value to enter is your AdSense Client ID
  • Click on Tags on the left side of the screen within your GTM workspace
  • Create a new Tag - Give it a name IE Adsense
  • Select the Custom HTML tag template and use the code from kbyte.snowpenguin.org/
  • Copy and Paste the HTML code shown below into GTM
  • Select the trigger All Pageviews
  • Test your changes in preview mode
  • Once everything is working correctly, you can publish the changes to LIVE.

Checking your installation

Once you're done with your installation, I highly recommend installing the Google Publisher Plugin in your chrome browser and link it up to both your Adsense and Analytics accounts. This in-browser tool will help you debug add placements and provide info on your ad performance. As I've said before, this isn't a recommended solution, and if it doesn't work for you, please don't come crying to me mailing me about how it's not running on your site.

Try to be a big boy or girl and hard code install it on your site. To those site owners using this method successfully, I highly recommend you keep tabs on bounce rate and page load speed before and after installation to make sure you're not sacrificing traffic for the sake of a shoddy implementation of AdSense.

Contact us

If you want to know more about publisher support, site monetization or debugging tools don’t be shy we’re happy to assist. Simply contact us here

Tags: Google Adsense, google tag manager, How to, Online advertising, Tools

Previous: {{ previousBlog.sTitle }}

Posted {{ previousBlog.dtDatePosting }}

Next: {{ nextBlog.sTitle }}

Posted {{ nextBlog.dtDatePosting }}

You might also like

Architect fees calculation

How Architects Calculate Their Fees

20 October 2024

Posted by Che Kohler in Constructive Criticism


Learn about factors influencing costs, common fee structures, and tips for negotiating fair rates. Get expert insights for your next project and meth...

Read more
Who benefits from Virtual Assistants

Who Needs Virtual Assistants?

19 October 2024

Posted by Che Kohler in Temping


Are you overwhelmed by administrative tasks? Discover how virtual assistants can save you time, money, and stress. Learn who can benefit most from hi...

Read more

Leave us a comment


{{comment.sUserName}}

{{comment.iDayLastEdit}} day ago

{{comment.iDayLastEdit}} days ago

{{comment.sComment}}

Sign up for our newsletter