Text Ads Text ads are text-based native ads that blend naturally with your website's content. They deliver high click-through rates and a good user experience, and their height adjusts automatically based on the content.
// HTML์ ์ปจํ
์ด๋ ์ค๋น
// <div id="text-container"></div>
// SDK ์ด๊ธฐํ (ํ ๋ฒ๋ง)
AdStage. init ({
apiKey: process.env. NEXT_PUBLIC_ADSTAGE_API_KEY
});
// ๊ธฐ๋ณธ ํ
์คํธ ๊ด๊ณ ์์ฑ
AdStage.ads. text ( 'text-container' );
AdStage.ads. text ( 'text-container' , {
onClick : ( adData ) => {
console. log ( 'ํ
์คํธ ๊ด๊ณ ํด๋ฆญ๋จ:' , adData);
// ์ฌ์ฉ์ ์ ์ ๋ก์ง ์ถ๊ฐ ๊ฐ๋ฅ
}
});
Option Type Default Description maxLinesnumber3Maximum number of lines to display stylestring'default'Style theme onClickfunctionundefinedCallback function executed on click
Option Type Default Description adIdstringundefinedSpecify a particular ad ID language'ko' | 'en' | 'ja' | 'zh'undefinedFilter by language deviceType'MOBILE' | 'DESKTOP'undefinedFilter by device country'KR' | 'US' | 'JP' | 'CN' | 'DE'undefinedFilter by country
Note : The height of text ads adjusts automatically based on the content length (height: 'auto').
HTML (CDN) JavaScript (ES6) React Next.js App Next.js Provider
The simplest CDN approach, which you can use directly in HTML.
<! DOCTYPE html >
< html >
< head >
< meta charset = "UTF-8" >
< title >ํ
์คํธ ๊ด๊ณ ์์ </ title >
</ head >
< body >
< h1 >๋ด ์น์ฌ์ดํธ</ h1 >
<!-- ํ
์คํธ ๊ด๊ณ ์ปจํ
์ด๋ -->
< div id = "text-container" style = "width: 100%; max-width: 600px; margin: 20px auto; padding: 16px; border: 1px solid #ddd; border-radius: 8px;" >
๋ก๋ฉ ์ค...
</ div >
<!-- AdStage SDK ๋ก๋ -->
< script src = "https://unpkg.com/@adstage/web-sdk/dist/index.umd.js" ></ script >
< script >
// SDK ์ด๊ธฐํ
AdStage. init ({
apiKey: 'your-api-key'
});
// ํ
์คํธ ๊ด๊ณ ์์ฑ
AdStage.ads. text ( 'text-container' , {
maxLines: 3
});
</ script >
</ body >
</ html >
You can limit the number of lines a text ad displays.
// 1์ค๋ก ์ ํ (ํ ์ค ํ
์คํธ ๊ด๊ณ )
AdStage.ads. text ( 'text-container' , {
maxLines: 1
});
// 5์ค๊น์ง ํ์ฉ
AdStage.ads. text ( 'text-container' , {
maxLines: 5
});
How to dynamically adjust the line count based on screen size.
// ๋ฏธ๋์ด ์ฟผ๋ฆฌ๋ฅผ ํ์ฉํ ๋ฐ์ํ ๊ตฌํ
const getResponsiveMaxLines = () => {
if (window.innerWidth <= 768 ) {
return 2 ; // ๋ชจ๋ฐ์ผ: 2์ค
} else if (window.innerWidth <= 1024 ) {
return 3 ; // ํ๋ธ๋ฆฟ: 3์ค
} else {
return 4 ; // ๋ฐ์คํฌํฑ: 4์ค
}
};
AdStage.ads. text ( 'text-container' , {
maxLines: getResponsiveMaxLines (),
deviceType: window.innerWidth <= 768 ? 'MOBILE' : 'DESKTOP'
});
// ์๋์ฐ ๋ฆฌ์ฌ์ด์ฆ ์ ์ฌ์์ฑ
window. addEventListener ( 'resize' , () => {
// ๊ธฐ์กด ๊ด๊ณ ์ ๊ฑฐ ํ ์๋ก ์์ฑ
AdStage.ads. destroy (slotId);
slotId = AdStage.ads. text ( 'text-container' , {
maxLines: getResponsiveMaxLines (),
deviceType: window.innerWidth <= 768 ? 'MOBILE' : 'DESKTOP'
});
});
Use this when you want to display only a specific text ad.
AdStage.ads. text ( 'text-container' , {
maxLines: 3 ,
adId: 'text-ad-456' // ํน์ ๊ด๊ณ ID
});
Use maxLines to specify the maximum number of lines to display (a number, default 3). The height of a text ad adjusts automatically (height: 'auto') to fit the content length.
// ์ต๋ 3์ค๋ก ํ์ (๊ธฐ๋ณธ๊ฐ)
AdStage.ads. text ( 'text-container' , {
maxLines: 3
});
Because ads load in the background, you receive the slot ID immediately.
// ์ฆ์ ์ฌ๋กฏ ID ๋ฐํ
const slotId = AdStage.ads. text ( 'text-container' );
console. log ( '์ฌ๋กฏ ์์ฑ๋จ:' , slotId); // ์ฆ์ ์คํ
// ์ค์ ๊ด๊ณ ๋ ๋น๋๊ธฐ๋ก ๋ก๋๋จ
When the container is removed from the DOM, the ad is also cleaned up automatically.
const slotId = AdStage.ads. text ( 'text-container' );
// DOM์์ ์ปจํ
์ด๋ ์ ๊ฑฐ ์ ์๋ ์ ๋ฆฌ๋จ
document. getElementById ( 'text-container' ). remove ();
// ์๋์ผ๋ก destroy() ํธ์ถํ ํ์ ์์
You can style your ads by leveraging the CSS classes the SDK adds automatically.
/* ๊ด๊ณ ์ปจํ
์ด๋ ๊ธฐ๋ณธ ์คํ์ผ */
.adstage-text-ad {
position : relative ;
overflow : hidden ;
font-family : inherit ;
line-height : 1.6 ;
}
/* ๋ก๋ฉ ์ํ */
.adstage-loading {
opacity : 0.7 ;
background : linear-gradient ( 90 deg , #f0f0f0 25 % , #e0e0e0 50 % , #f0f0f0 75 % );
background-size : 200 % 100 % ;
animation : loading 1.5 s infinite ;
}
@keyframes loading {
0% { background-position : 200 % 0 ; }
100% { background-position : -200 % 0 ; }
}
/* ๋ก๋ฉ ์๋ฃ */
.adstage-loaded {
opacity : 1 ;
transition : opacity 0.3 s ease ;
}
/* ์ค๋ฅ ์ํ */
.adstage-error {
border : 1 px solid #ff6b6b ;
background-color : #ffe0e0 ;
}
// ๋ชจ๋ ์ฌ๋กฏ ํ์ธ
const allSlots = AdStage.ads. getAllSlots ();
console. log ( '์ ์ฒด ๊ด๊ณ ์ฌ๋กฏ:' , allSlots);
// ํน์ ์ฌ๋กฏ ํ์ธ
const slot = AdStage.ads. getSlotById (slotId);
console. log ( '์ฌ๋กฏ ์ ๋ณด:' , slot);