Documentation

SDK Reference

Everything you need to integrate AdPulse SDK into any website or JavaScript framework.

Installation

Add the SDK script once to your HTML <head>. It loads asynchronously and has zero impact on page performance.

index.htmlhtml
<!-- Option A: CDN (recommended) -->
<script src="https://vulnera.online/sdk.js" async></script>

<!-- Option B: npm -->
npm install @adpulse/sdk

Basic Usage

Place an .adpulse-ad div anywhere in your page. Configure with data-* attributes.

index.htmlhtml
<!-- Minimal inline ad -->
<div class="adpulse-ad" data-ad-id="ad_9x3kz" data-publisher-key="ap_live_pk_..."></div>

<!-- Full configuration -->
<div class="adpulse-ad" data-ad-id="ad_9x3kz" data-publisher-key="ap_live_pk_..." data-position="inline" data-animation="fadeUp" data-theme="dark" data-template="classic" data-accent="#22c55e" data-background="#12103a" data-text-color="#ffffff" data-cta-style="filled" data-card-size="standard" data-delay="300" data-cta="Get Started Free" data-closeable="true" data-show-icon="true" data-show-badge="true" data-show-description="false" data-lazy="true" data-radius="12"
></div>

Custom Templates

Each ad can save its own card template from the advertiser builder. The SDK uses that saved design automatically, and individual placements can override template fields with optional attributes.

Classic

Balanced default card with icon, headline, supporting text, and button.

Minimal

Quiet text-first card for blogs, docs, and content-heavy pages.

Media

Visual card with an image area for product shots, banners, or brand art.

Spotlight

High-emphasis card for launches, offers, and floating promotions.

template-overrides.htmlhtml
<!-- Saved template is used automatically -->
<div class="adpulse-ad" data-ad-id="ad_9x3kz" data-publisher-key="ap_live_pk_..."></div>

<!-- Optional per-page override -->
<div class="adpulse-ad" data-ad-id="ad_9x3kz" data-publisher-key="ap_live_pk_..." data-template="media" data-image="https://example.com/product-shot.jpg" data-background="#10172a" data-accent="#38bdf8" data-cta-style="outline"
></div>

Parameters Reference

AttributeTypeRequiredDefaultDescription
data-ad-idstringYes-Copy this from Dashboard > Publisher Keys or Tracked Ads after binding an ad
data-publisher-keystringYes-Your bound publisher key for this website and ad
data-positionstringNoinlineinline | sidebar | float | banner | overlay
data-animationstringNofadeUpfadeUp | fadeIn | slideRight | slideLeft | bounceSoft | none
data-themestringNodarkdark | light | auto (follows system preference)
data-templatestringNosaved ad settingclassic | minimal | media | spotlight
data-accentcolorNo#22c55eCSS color for buttons and highlights. Accepts hex, rgb, hsl.
data-backgroundcolorNosaved ad settingCard background color. Hex colors are recommended.
data-text-colorcolorNo#ffffffPrimary text color for the ad card.
data-cta-stylestringNofilledfilled | outline | link
data-card-sizestringNostandardcompact | standard | large
data-imagestringNo-Image URL used by the media template.
data-show-iconbooleanNotrueShow or hide the icon area.
data-show-badgebooleanNotrueShow or hide the badge text.
data-show-descriptionbooleanNofalseShow or hide the longer description on roomy templates.
data-delaynumberNo0Milliseconds before rendering the card after page load
data-ctastringNoLearn MoreCustom call-to-action button label
data-closeablebooleanNofalseShow an X button letting users dismiss the ad
data-lazybooleanNotrueOnly render when card enters the viewport (IntersectionObserver)
data-radiusnumberNo12Card border radius in pixels

JavaScript API

For more control, use the programmatic JavaScript API. Import the SDK as an ES module and manage ads in code.

app.jsjavascript
// Programmatic initialization
import AdPulse from '@adpulse/sdk';

const sdk = new AdPulse({ publisherKey: 'ap_live_sk_...' });

// Render a single ad
sdk.render('#my-ad-slot', {
  adId: 'ad_9x3kz',
  position: 'float',
  animation: 'slideLeft',
  accentColor: '#38bdf8',
});

// Listen to events
sdk.on('impression', (data) => console.log('Ad viewed:', data));
sdk.on('click', (data) => console.log('Ad clicked:', data));
sdk.on('dismiss', (data) => console.log('Ad dismissed:', data));

React / Next.js

Use the official React wrapper for seamless JSX integration. Fully typed with TypeScript.

BlogPost.tsxtsx
// React / Next.js component
import { AdSlot } from '@adpulse/react';

export default function BlogPost() {
  return (
    <article>
      <h1>Your Article</h1>
      <p>First paragraph...</p>

      {/* Drop anywhere in JSX */}
      <AdSlot
        adId="ad_9x3kz"
        position="inline"
        animation="fadeUp"
        accentColor="#22c55e"
        closeable
      />

      <p>Second paragraph...</p>
    </article>
  );
}

Events

EventPayloadDescription
impression{ adId, timestamp }Fired when the ad enters the viewport
click{ adId, href, timestamp }Fired when the CTA button is clicked
dismiss{ adId, timestamp }Fired when user closes the ad
render{ adId, position }Fired when the card finishes rendering
error{ adId, error }Fired if the ad fails to load

Ready to start?

Try the live preview builder to generate your embed code instantly.

Open Preview Builder →