Improving ad performance with the new AdSense code

Created on 1 August 2021, over 3 years ago
Updated 6 May 2024, 11 months ago

Problem/Motivation

Google recently launched a new version of the AdSense code. The new AdSense code allows AdSense to trigger optimization features earlier which can improve the performance of the ads on your site. The new ad code works for both Auto ads and ad units.

Proposed resolution

Auto ads code example:

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234" crossorigin="anonymous"</script>

Ad unit code example:

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234" crossorigin="anonymous"</script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-1234"
     data-ad-slot="5678"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>

Source

Google Announcements from July 19, 2021

Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇷🇸Serbia bataboza

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024