Use js to call Google ads

Source: Internet
Author: User

Insert a Google Adsense advertisement into a webpage.Source codeDirectly embed the topic template page. In fact, Google Adsense supports and allows JS file calls. Of course, the premise is not to modify it for any reason.Code, Or manually affects the positioning of the advertisement. This will be compromised by Google accounts for violation of the Plan policy.

Taking the classic AD Size code of 468x60 as an example, Mango describes how to call JS files.

The code for getting an advertisement unit is as follows:

 
<SCRIPT type = "text/JavaScript"> <! -- Google_ad_client = "publisher ID";/* 468x60, created in XX-xx */google_ad_slot = "xxxxxxxxxx"; google_ad_width = 468; google_ad_height = 60; // --> </SCRIPT> <SCRIPT type = "text/JavaScript" src = "http://pagead2.googlesyndication.com/pagead/show_ads.js"> </SCRIPT>

After getting this code, you need to convert it to the JS form:

Document. writeln ("<SCRIPT type = \" text \/JavaScript \ "> <! -- "); Document. writeln ("google_ad_client = \" publisher ID \ ";"); document. writeln ("\/* 468x60, created in XX-xx * \/"); document. writeln ("google_ad_slot = \" xxxxxxxxxx \ ";"); document. writeln ("google_ad_width = 468;"); document. writeln ("google_ad_height = 60;"); document. writeln ("\/-->"); document. writeln ("<\/SCRIPT>"); document. writeln ("<SCRIPT type = \" text \/JavaScript \ ""); document. writeln ("src = \" http: \// pagead2.googlesyndication.com \/pagead \/show_ads.js \ ">"); document. writeln ("<\/SCRIPT> ")

In view of the trouble to manually change, it is recommended to use online HTML to JS tools, such as: http://www.hao123.com/haoserver/jstohtm.htm
Save the converted code as a JS file by calling the following method:

 
<Script language = "JavaScript" src = "ggad_468x60.js" type = "text/JavaScript"> </SCRIPT>

Of course, for powerful WordPressProgramYou can use various AdSense advertising management plug-ins to manage code. In addition, this method is not limited to AdSense, and is also applicable to other advertisers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.