Ad code implementation
Where to place the ad code in your HTML (Auto ads)
After you've generated the ad code for your Auto ads, you'll need to place the code once on each page that you want to show the ads. You should place your ad code in the <head>
tag (or at the top of the body) of your page.
The following examples show you where to place the code:
Example HTML page before the Auto ad code has been added
<html>
<head>
This is the head of your page.
<title>Example HTML page</title>
</head>
<body>
This is the body of your page.
</body>
</html>
Example HTML page with the Auto ad code added in the <head>
tag
<html>
<head>
<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-123456789",
enable_page_level_ads: true
});
</script>
This is the head of your page.
<title>Example HTML page</title>
</head>
<body>
This is the body of your page.
</body>
</html>
Example HTML page with the Auto ad code added at the top of the body
If you don't have access to the <head>
tags of your page, you can place the ad code at the top of the body instead:
<html>
<head>
This is the head of your page
<title>Example HTML page</title>
</head>
<body>
<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-123456789",
enable_page_level_ads: true
});
</script>
This is the body of your page.
</body>
</html>