StageUp
Web SDKAdvertisements

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.

๐ŸŽฏ Basic Usage

Simple Text Ad

// HTML์— ์ปจํ…Œ์ด๋„ˆ ์ค€๋น„
// <div id="text-container"></div>
 
// SDK ์ดˆ๊ธฐํ™” (ํ•œ ๋ฒˆ๋งŒ)
AdStage.init({
  apiKey: process.env.NEXT_PUBLIC_ADSTAGE_API_KEY
});
 
// ๊ธฐ๋ณธ ํ…์ŠคํŠธ ๊ด‘๊ณ  ์ƒ์„ฑ
AdStage.ads.text('text-container');

Handling Click Events

AdStage.ads.text('text-container', {
  onClick: (adData) => {
    console.log('ํ…์ŠคํŠธ ๊ด‘๊ณ  ํด๋ฆญ๋จ:', adData);
    // ์‚ฌ์šฉ์ž ์ •์˜ ๋กœ์ง ์ถ”๊ฐ€ ๊ฐ€๋Šฅ
  }
});

โš™๏ธ Configuration Options

Basic Options

OptionTypeDefaultDescription
maxLinesnumber3Maximum number of lines to display
stylestring'default'Style theme
onClickfunctionundefinedCallback function executed on click

Filtering Options

OptionTypeDefaultDescription
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').

๐Ÿ’ก Real-World Implementation Examples

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>

๐Ÿš€ Advanced Features

Limiting the Line Count

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
});

Responsive Line Count Adjustment

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'
  });
});

Specifying a Particular Ad ID

Use this when you want to display only a specific text ad.

AdStage.ads.text('text-container', {
  maxLines: 3,
  adId: 'text-ad-456'  // ํŠน์ • ๊ด‘๊ณ  ID
});

๐Ÿ”ง Optimization Tips

1. Specifying the Line Count

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
});

2. Background Loading

Because ads load in the background, you receive the slot ID immediately.

// ์ฆ‰์‹œ ์Šฌ๋กฏ ID ๋ฐ˜ํ™˜
const slotId = AdStage.ads.text('text-container');
console.log('์Šฌ๋กฏ ์ƒ์„ฑ๋จ:', slotId);  // ์ฆ‰์‹œ ์‹คํ–‰
 
// ์‹ค์ œ ๊ด‘๊ณ ๋Š” ๋น„๋™๊ธฐ๋กœ ๋กœ๋“œ๋จ

3. Leveraging Automatic Cleanup

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() ํ˜ธ์ถœํ•  ํ•„์š” ์—†์Œ

๐ŸŽจ Styling

Using CSS Classes

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(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}
 
@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
 
/* ๋กœ๋”ฉ ์™„๋ฃŒ */
.adstage-loaded {
  opacity: 1;
  transition: opacity 0.3s ease;
}
 
/* ์˜ค๋ฅ˜ ์ƒํƒœ */
.adstage-error {
  border: 1px solid #ff6b6b;
  background-color: #ffe0e0;
}

Checking Slot Status

// ๋ชจ๋“  ์Šฌ๋กฏ ํ™•์ธ
const allSlots = AdStage.ads.getAllSlots();
console.log('์ „์ฒด ๊ด‘๊ณ  ์Šฌ๋กฏ:', allSlots);
 
// ํŠน์ • ์Šฌ๋กฏ ํ™•์ธ
const slot = AdStage.ads.getSlotById(slotId);
console.log('์Šฌ๋กฏ ์ •๋ณด:', slot);

Table of Contents