JDProwler
JDProwler

Reputation: 109

inserting google advertisements with html

Good day,

I'm sorry if this might be a duplicate question but most of the questions speak of Google AdSense and I've never used that.

Getting to the point, I would like to know if anyone knows how to add an advertisement from Google to an HTML 5 site.

I am doing a project. The actual site files will be on the local drive, but I would like to i.e. insert an on my page that would draw some random Google Ads and place them in this section.

I do not wish to create an advert or anything of the sort. Let's say that I have the section at a 600px by 100px block, I would like to have that "draw" any ads of a certain category to be placed there at run time.

Like I said the page itself will be local, but using internet access the page should fetch these ads.

Thank you in advance for a speedy reply, and I would like to apologize if I over explained.

Upvotes: 7

Views: 18748

Answers (4)

Niresh
Niresh

Reputation: 669

Adsense can not be loaded from localhost or from a saved html file. It will not work. Google checks if the domain is accepted into adsense before showing an ad. So when you load an ad from local, domain property will be missing.

Upvotes: 1

Josue
Josue

Reputation: 11

<html>
<head>
This is the head of your page
<title>Example HTML page</title>
</head>
<body>
This is the body of your page.

<!-- Ad block -->
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1234567890123456"
data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<!-- End of Ad block -->

</body>
</html>

Upvotes: 0

Anurag M.
Anurag M.

Reputation: 156

It is very easy to insert the Google Adsense in HTML just paste your code inside the body tag and use bootstrap or CSS3 for the positioning.

<html>
    <head>
        This is the head of your page
        <title>Example HTML page</title>
    </head>
    <body>
        **Paste your google adsense code inside the body**
        This is the body of your page.
        <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
        <!-- Homepage Leaderboard -->
        <ins class="adsbygoogle"
            style="display:inline-block;width:728px;height:90px"
            data-ad-client="ca-pub-1234567890123456"
            data-ad-slot="1234567890"></ins>
        <script>
            (adsbygoogle = window.adsbygoogle || []).push({});
        </script>
    </body>
</html>

Upvotes: 7

Mark Perera
Mark Perera

Reputation: 662

Refer Get and copy the ad code (click "If you haven't yet created an ad unit under "How to get and copy your ad code")
Then refer Where to paste the ad code in your HTML

It's explained pretty well

Upvotes: 0

Related Questions