Advertising System Overview
The AdStage Web SDK supports three types of ads in web applications.
Image-based ads, the most common format.
AdStage.ads.banner('banner-container', {
width: '100%',
height: 250
});
Features: Image-based, automatic resizing, slide support
Text-based native ads that integrate naturally with your content.
AdStage.ads.text('text-container');
Features: Automatic height adjustment, line count limit, native styling
Video-based ads that deliver high engagement.
AdStage.ads.video('video-container', {
width: 640,
height: 360,
autoplay: true,
muted: true
});
Features: HTML5 video, autoplay/mute, mobile optimization
- Initialize the SDK - Configure with
AdStage.init()
- Prepare a container - Create an ad display area in your HTML
- Request an ad - Call
ads.banner(), ads.text(), or ads.video()
- Automatic rendering - Ads load and display in the background
- Event tracking - Impressions/clicks are collected automatically
Check out the detailed usage guide for each ad type:
Image-based banner ads, the most common form of web advertising.
// ๊ธฐ๋ณธ ๋ฐฐ๋ ๊ด๊ณ
AdStage.ads.banner('banner-container', {
width: '100%',
height: 250
});
// ํด๋ฆญ ์ด๋ฒคํธ ์ฒ๋ฆฌ ๋ฐ ๊ณ ๊ธ ์ต์
AdStage.ads.banner('banner-container', {
width: '100%',
height: 250,
onClick: (adData) => {
console.log('๋ฐฐ๋ ๊ด๊ณ ํด๋ฆญ:', adData);
}
});
Key features:
- Dynamic resizing (automatically optimized based on image size)
- Fast response with background loading
- Automatic slide support (for multiple ads)
Text-based native ads that blend naturally with your content.
// ๊ธฐ๋ณธ ํ
์คํธ ๊ด๊ณ
AdStage.ads.text('text-container', {
maxLines: 3
});
// ํด๋ฆญ ์ด๋ฒคํธ ์ฒ๋ฆฌ
AdStage.ads.text('text-container', {
maxLines: 3,
onClick: (adData) => {
console.log('ํ
์คํธ ๊ด๊ณ ํด๋ฆญ:', adData);
}
});
Key features:
- Automatically fits to content height (height: 'auto')
- Natural integration with your site design
- Maximum line count limit available
Video-based ads that deliver high engagement.
// ๊ธฐ๋ณธ ๋น๋์ค ๊ด๊ณ (๊ธฐ๋ณธ๊ฐ: ์๋์ฌ์, ์์๊ฑฐ, ์ปจํธ๋กค ์จ๊น)
AdStage.ads.video('video-container', {
width: 640,
height: 360,
autoplay: true, // ๊ธฐ๋ณธ๊ฐ: true
muted: true, // ๊ธฐ๋ณธ๊ฐ: true
controls: false // ๊ธฐ๋ณธ๊ฐ: false
});
// ์ฌ์ฉ์ ์ ์ด ๊ฐ๋ฅํ ๋น๋์ค ๊ด๊ณ
AdStage.ads.video('video-container', {
width: 640,
height: 360,
autoplay: false,
muted: false,
controls: true,
onClick: (adData) => {
console.log('๋น๋์ค ๊ด๊ณ ํด๋ฆญ:', adData);
}
});
Key features:
- Optimized for a single video (maxAds: 1)
- HTML5 video player
- Mobile inline playback support (playsinline: true)
- Loop playback enabled by default (loop: true)
graph TD
A[SDK ์ด๊ธฐํ] --> B[๊ด๊ณ ์ปจํ
์ด๋ ํ์ง]
B --> C[๊ด๊ณ ์์ฒญ]
C --> D[๊ด๊ณ ์๋ต ์์ ]
D --> E[๊ด๊ณ ๋ ๋๋ง]
E --> F[๋
ธ์ถ ์ด๋ฒคํธ ์ ์ก]
F --> G[์ฌ์ฉ์ ์ํธ์์ฉ ์ถ์ ]
- Initialization: Configure the SDK with
AdStage.init()
- Container preparation: Create the element where the ad will be displayed in your HTML
- Ad request: Request ad content from the server
- Rendering: Display the received ad in the specified container
- Tracking: Automatically track impression and click events
Options available for all ad types:
| Option | Type | Default | Description |
|---|
onClick | function | undefined | Callback function on ad click |
adId | string | undefined | Specify a particular ad ID |
language | 'ko' | 'en' | 'ja' | 'zh' | undefined | Language filter |
deviceType | 'MOBILE' | 'DESKTOP' | undefined | Device type filter |
country | 'KR' | 'US' | 'JP' | 'CN' | 'DE' | undefined | Country filter |
| Option | Type | Default | Description |
|---|
width | string | number | '100%' | Ad width |
height | number | 250 | Ad height (banner defaults to 250px) |
autoSlide | boolean | false | Automatic slide for multiple ads |
slideInterval | number | 5000 | Slide interval (ms) |
| Option | Type | Default | Description |
|---|
maxLines | number | 3 | Maximum number of lines |
style | string | 'default' | Style theme |
Note: The height of text ads is automatically adjusted based on content (height: 'auto').
| Option | Type | Default | Description |
|---|
width | number | 640 | Video width |
height | number | 360 | Video height |
autoplay | boolean | true | Autoplay |
muted | boolean | true | Mute |
loop | boolean | true | Loop playback |
controls | boolean | false | Show controls |
playsinline | boolean | true | Inline playback (mobile) |
hideControls | boolean | false | Hide all controls |
customControls | object | undefined | Detailed control settings |
customControls: {
hidePlayButton: boolean, // ์ฌ์ ๋ฒํผ ์จ๊ธฐ๊ธฐ
hideProgressBar: boolean, // ์งํ๋ฐ ์จ๊ธฐ๊ธฐ
hideCurrentTime: boolean, // ํ์ฌ ์๊ฐ ์จ๊ธฐ๊ธฐ
hideRemainingTime: boolean, // ๋จ์ ์๊ฐ ์จ๊ธฐ๊ธฐ
hideVolumeSlider: boolean, // ๋ณผ๋ฅจ ์ฌ๋ผ์ด๋ ์จ๊ธฐ๊ธฐ
hideMuteButton: boolean, // ์์๊ฑฐ ๋ฒํผ ์จ๊ธฐ๊ธฐ
hideFullscreenButton: boolean // ์ ์ฒดํ๋ฉด ๋ฒํผ ์จ๊ธฐ๊ธฐ
}
// ํน์ ๊ด๊ณ ID๋ก ๋ฐฐ๋ ๊ด๊ณ ํ์
AdStage.ads.banner('my-banner', {
width: '100%',
height: 250,
adId: 'specific-ad-123',
language: 'ko',
deviceType: 'DESKTOP',
onClick: (adData) => {
console.log('๊ด๊ณ ํด๋ฆญ:', adData);
// ์ฌ์ฉ์ ์ ์ ์ถ์ ๋ก์ง
}
});
// ์ปค์คํ
์ปจํธ๋กค์ด ์๋ ๋น๋์ค ๊ด๊ณ
AdStage.ads.video('video-container', {
width: 640,
height: 360,
autoplay: false,
muted: false,
controls: true,
customControls: {
hideFullscreenButton: true,
hideVolumeSlider: false,
hideProgressBar: false
}
});
The SDK automatically loads ads in the background:
// ์ฌ๋กฏ ID๋ ์ฆ์ ๋ฐํ, ๊ด๊ณ ๋ ๋ฐฑ๊ทธ๋ผ์ด๋์์ ๋ก๋
const slotId = AdStage.ads.banner('banner-ad');
console.log('์ฌ๋กฏ ์์ฑ๋จ:', slotId); // ์ฆ์ ์คํ
// ์ค์ ๊ด๊ณ ๋ ๋น๋๊ธฐ๋ก ๋ก๋๋์ด ๋ ๋๋ง๋จ
Ad containers removed from the DOM are cleaned up automatically:
// MutationObserver๋ฅผ ํตํ ์๋ ๊ฐ์ง ๋ฐ ์ ๋ฆฌ
// ๊ฐ๋ฐ์๊ฐ ์๋์ผ๋ก destroy()๋ฅผ ํธ์ถํ ํ์ ์์
const slotId = AdStage.ads.banner('banner-ad');
// DOM์์ ์ปจํ
์ด๋๊ฐ ์ ๊ฑฐ๋๋ฉด ์๋์ผ๋ก ์ฌ๋กฏ๋ ์ ๋ฆฌ๋จ
document.getElementById('banner-ad').remove();
Automatically retries when the container is not found:
// ์ปจํ
์ด๋๊ฐ ์์ง ์กด์ฌํ์ง ์์๋ ์ ์ง์ ์ผ๋ก ์ฌ์๋
const slotId = AdStage.ads.banner('not-yet-exists', {
width: '100%',
height: 250
});
// ๋์ค์ DOM์ ์ปจํ
์ด๋๊ฐ ์ถ๊ฐ๋๋ฉด ์๋์ผ๋ก ๊ด๊ณ ํ์
setTimeout(() => {
const div = document.createElement('div');
div.id = 'not-yet-exists';
document.body.appendChild(div);
}, 1000);
CSS classes the SDK adds automatically:
/* ๊ด๊ณ ์ปจํ
์ด๋ */
.adstage-ad {
position: relative;
overflow: hidden;
}
/* ๋ก๋ฉ ์ํ */
.adstage-loading {
opacity: 0.7;
}
/* ๋ก๋ฉ ์๋ฃ */
.adstage-loaded {
opacity: 1;
transition: opacity 0.3s ease;
}
/* ์ค๋ฅ ์ํ */
.adstage-error {
border: 1px solid #ff0000;
}
Ad settings tailored to various screen sizes:
AdStage.ads.banner('responsive-banner', {
width: '100%',
height: window.innerWidth > 768 ? 250 : 100
});
The SDK can be used in JavaScript, React, and Next.js environments. Learn how to implement it through real-world examples.
How to load and use the UMD build directly in an HTML file.
<!DOCTYPE html>
<html>
<head>
<title>AdStage SDK Example</title>
</head>
<body>
<!-- ๊ด๊ณ ์ปจํ
์ด๋ -->
<div id="banner-ad">๋ฐฐ๋ ๊ด๊ณ ๊ฐ ๋ก๋ ์ค์
๋๋ค...</div>
<div id="text-ad">ํ
์คํธ ๊ด๊ณ ๊ฐ ๋ก๋ ์ค์
๋๋ค...</div>
<div id="video-ad">๋น๋์ค ๊ด๊ณ ๊ฐ ๋ก๋ ์ค์
๋๋ค...</div>
<!-- SDK ๋ก๋ -->
<script src="https://unpkg.com/@adstage/web-sdk/dist/index.umd.js"></script>
<script>
// SDK ์ด๊ธฐํ
AdStage.init({
apiKey: 'your-api-key',
debug: true
});
// ๊ด๊ณ ์์ฑ
const bannerSlotId = AdStage.ads.banner('banner-ad', {
width: '100%',
height: 250,
onClick: (adData) => console.log('๋ฐฐ๋ ํด๋ฆญ:', adData)
});
const textSlotId = AdStage.ads.text('text-ad', {
maxLines: 3,
onClick: (adData) => console.log('ํ
์คํธ ํด๋ฆญ:', adData)
});
const videoSlotId = AdStage.ads.video('video-ad', {
width: 640,
height: 360,
autoplay: true,
muted: true,
controls: false,
onClick: (adData) => console.log('๋น๋์ค ํด๋ฆญ:', adData)
});
</script>
</body>
</html>
How to use the SDK directly in React.
import React, { useEffect, useRef } from 'react';
import { AdStage } from '@adstage/web-sdk';
function AdComponent() {
const bannerRef = useRef(null);
const textRef = useRef(null);
const videoRef = useRef(null);
const slotIdsRef = useRef({});
useEffect(() => {
// SDK ์ด๊ธฐํ
AdStage.init({
apiKey: 'your-api-key',
debug: true
});
// ๊ด๊ณ ์์ฑ
if (bannerRef.current) {
slotIdsRef.current.banner = AdStage.ads.banner(bannerRef.current, {
width: '100%',
height: 250,
onClick: (adData) => console.log('๋ฐฐ๋ ํด๋ฆญ:', adData)
});
}
if (textRef.current) {
slotIdsRef.current.text = AdStage.ads.text(textRef.current, {
maxLines: 3,
onClick: (adData) => console.log('ํ
์คํธ ํด๋ฆญ:', adData)
});
}
if (videoRef.current) {
slotIdsRef.current.video = AdStage.ads.video(videoRef.current, {
width: 640,
height: 360,
autoplay: true,
muted: true,
controls: false,
onClick: (adData) => console.log('๋น๋์ค ํด๋ฆญ:', adData)
});
}
// ์ ๋ฆฌ ํจ์
return () => {
Object.values(slotIdsRef.current).forEach(slotId => {
if (slotId) AdStage.ads.destroy(slotId);
});
};
}, []);
return (
<div>
<h1>AdStage SDK - React ์์ </h1>
<div style={{ margin: '20px 0' }}>
<h2>Banner Advertisement</h2>
<div
ref={bannerRef}
style={{
minHeight: '100px',
border: '2px dashed #ccc',
borderRadius: '4px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
}}
>
๋ฐฐ๋ ๊ด๊ณ ๊ฐ ๋ก๋ ์ค์
๋๋ค...
</div>
</div>
<div style={{ margin: '20px 0' }}>
<h2>Text Advertisement</h2>
<div ref={textRef}>
ํ
์คํธ ๊ด๊ณ ๊ฐ ๋ก๋ ์ค์
๋๋ค...
</div>
</div>
<div style={{ margin: '20px 0' }}>
<h2>Video Advertisement</h2>
<div ref={videoRef}>
๋น๋์ค ๊ด๊ณ ๊ฐ ๋ก๋ ์ค์
๋๋ค...
</div>
</div>
</div>
);
}
export default AdComponent;
The recommended approach using AdStageProvider in Next.js.
// pages/_app.js
import { AdStageProvider } from '@adstage/web-sdk';
export default function App({ Component, pageProps }) {
return (
<AdStageProvider
config={{
apiKey: 'your-api-key',
debug: true
}}
>
<Component {...pageProps} />
</AdStageProvider>
);
}
// pages/index.js
import { useEffect, useRef } from 'react';
import { useAdStageInstance } from '@adstage/web-sdk';
export default function Home() {
const adstage = useAdStageInstance();
const bannerRef = useRef(null);
const textRef = useRef(null);
const videoRef = useRef(null);
const slotIdsRef = useRef({});
useEffect(() => {
if (adstage) {
loadAds();
}
return () => {
// ์ปดํฌ๋ํธ ์ธ๋ง์ดํธ ์ ์ ๋ฆฌ
Object.values(slotIdsRef.current).forEach(slotId => {
if (slotId) adstage?.ads?.destroy(slotId);
});
};
}, [adstage]);
const loadAds = () => {
// ๋ฐฐ๋ ๊ด๊ณ
if (bannerRef.current) {
slotIdsRef.current.banner = adstage.ads.banner(bannerRef.current, {
width: '100%',
height: 250,
onClick: (adData) => console.log('๋ฐฐ๋ ํด๋ฆญ:', adData)
});
}
// ํ
์คํธ ๊ด๊ณ
if (textRef.current) {
slotIdsRef.current.text = adstage.ads.text(textRef.current, {
maxLines: 3,
onClick: (adData) => console.log('ํ
์คํธ ํด๋ฆญ:', adData)
});
}
// ๋น๋์ค ๊ด๊ณ
if (videoRef.current) {
slotIdsRef.current.video = adstage.ads.video(videoRef.current, {
width: 640,
height: 360,
autoplay: true,
muted: true,
controls: false,
onClick: (adData) => console.log('๋น๋์ค ํด๋ฆญ:', adData)
});
}
};
return (
<div style={{ fontFamily: 'Arial, sans-serif', margin: '20px' }}>
<h1>AdStage SDK - Next.js ๊ด๊ณ ์์ </h1>
{/* ๋ฐฐ๋ ๊ด๊ณ */}
<div style={{ margin: '40px 0', padding: '20px', border: '1px solid #ddd' }}>
<h2>Banner Advertisement</h2>
<div
ref={bannerRef}
style={{
minHeight: '100px',
border: '2px dashed #ccc',
borderRadius: '4px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
}}
>
๋ฐฐ๋ ๊ด๊ณ ๊ฐ ๋ก๋ ์ค์
๋๋ค...
</div>
</div>
{/* ํ
์คํธ ๊ด๊ณ */}
<div style={{ margin: '40px 0', padding: '20px', border: '1px solid #ddd' }}>
<h2>Text Advertisement</h2>
<div
ref={textRef}
style={{
backgroundColor: 'rgba(34, 197, 94, 0.1)',
borderRadius: '12px',
border: '1px solid rgba(34, 197, 94, 0.2)',
padding: '16px',
minHeight: '80px'
}}
>
ํ
์คํธ ๊ด๊ณ ๊ฐ ๋ก๋ ์ค์
๋๋ค...
</div>
</div>
{/* ๋น๋์ค ๊ด๊ณ */}
<div style={{ margin: '40px 0', padding: '20px', border: '1px solid #ddd' }}>
<h2>Video Advertisement</h2>
<div
ref={videoRef}
style={{
minHeight: '100px',
border: '2px dashed #ccc',
borderRadius: '4px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
}}
>
๋น๋์ค ๊ด๊ณ ๊ฐ ๋ก๋ ์ค์
๋๋ค...
</div>
</div>
</div>
);
}