หลังจากสร้างสไตล์โฆษณาใน Search แล้ว ให้ทำตามขั้นตอนต่อไปนี้เพื่อคัดลอกและวางโค้ดลงในหน้าค้นหา
- ลงชื่อเข้าใช้บัญชี AdSense
- คลิกโฆษณาสำหรับเครือข่ายการค้นหา จากนั้นคลิกสไตล์โฆษณาใน Search
- คลิกสร้างรหัส
- ในหน้า "เครื่องมือสร้างโค้ด" ให้ทำดังนี้
- ในส่วน "ขั้นตอนที่ 1: สร้างคอนเทนเนอร์" ให้ทำดังนี้
- เพิ่มรหัส HTML DIV ของคอนเทนเนอร์โฆษณาในหน้าค้นหา หรือคุณสามารถใช้ชื่อคอนเทนเนอร์เริ่มต้น (เช่น afscontainer1) และอัปเดตรหัส DIV บนหน้าเว็บให้ตรงกัน
- (ไม่บังคับ) คลิก เพิ่มคอนเทนเนอร์ เพื่อเพิ่มรหัส HTML ของคอนเทนเนอร์อื่น
- ในส่วน "ขั้นตอนที่ 2: คัดลอกและวางโค้ด" ให้ทำดังนี้
- คัดลอกและวางข้อมูลโค้ดรายการแรกลงในแท็ก
<head>
ของหน้าค้นหา - คัดลอกและวางข้อมูลโค้ดรายการที่ 2 ลงในแท็ก
<body>
ของหน้าการค้นหา
- คัดลอกและวางข้อมูลโค้ดรายการแรกลงในแท็ก
- ในส่วน "ขั้นตอนที่ 1: สร้างคอนเทนเนอร์" ให้ทำดังนี้
- เมื่อดำเนินการเสร็จสิ้น ให้คลิกเสร็จแล้ว
ตัวอย่างโค้ด
ต่อไปนี้เป็นตัวอย่างหน้าผลการค้นหาที่มีข้อมูลโค้ดที่เพิ่มเข้าไปทั้ง 2 รายการ
หมายเหตุ: การคัดลอกโค้ดจากตัวอย่างนี้ไปใช้จะทำให้โฆษณาบนเครือข่ายการค้นหาของคุณไม่ทำงาน ตรวจสอบให้แน่ใจว่าคุณได้คัดลอกและวางโค้ดจากบัญชี AdSense ของคุณโดยตรง
<html>
<head>
<script async="async" src="https://www.google.com/adsense/search/ads.js"></script>
<!-- other head elements from your page -->
<script type="text/javascript" charset="utf-8">
(function(g,o){g[o]=g[o]||function(){(g[o]['q']=g[o]['q']||[]).push(
arguments)},g[o]['t']=1*new Date})(window,'_googCsa');
</script>
</head>
<body>
<div id="afscontainer1"></div>
<div id="afscontainer2"></div>
<script type="text/javascript" charset="utf-8">
var pageOptions = {
"pubId": "partner-pub-1234567891234567", // Make sure this is the correct client ID
"styleId": "1234567891", // Make sure this is the correct style id
"query": "" // Make sure the correct query is placed here
};
var adblock1 = {
"container": "afscontainer1",
};
var adblock2 = {
"container": "afscontainer2",
};
_googCsa('ads', pageOptions, adblock1, adblock2);
</script>
</body>
</html>
<head>
<script async="async" src="https://www.google.com/adsense/search/ads.js"></script>
<!-- other head elements from your page -->
<script type="text/javascript" charset="utf-8">
(function(g,o){g[o]=g[o]||function(){(g[o]['q']=g[o]['q']||[]).push(
arguments)},g[o]['t']=1*new Date})(window,'_googCsa');
</script>
</head>
<body>
<div id="afscontainer1"></div>
<div id="afscontainer2"></div>
<script type="text/javascript" charset="utf-8">
var pageOptions = {
"pubId": "partner-pub-1234567891234567", // Make sure this is the correct client ID
"styleId": "1234567891", // Make sure this is the correct style id
"query": "" // Make sure the correct query is placed here
};
var adblock1 = {
"container": "afscontainer1",
};
var adblock2 = {
"container": "afscontainer2",
};
_googCsa('ads', pageOptions, adblock1, adblock2);
</script>
</body>
</html>