Launch your first ad campaign in five steps. This guide walks you through authentication, campaign creation, ad serving, and conversion tracking.
tenant-id (found in your account settings)Obtain a JWT access token by logging in via the Auth API. Include this token and your tenant ID in every request.
import { Client } from '@eventzr/auth-client';
const authClient = new Client({
baseUrl: 'https://api.eventzr.com/auth/v1',
tenantId: '<your-tenant-id>',
});
const { data } = await authClient.login({
email: 'dev@yourcompany.com',
password: '<password>',
});
const accessToken = data.accessToken;
// Use this token in the Authorization header for all Ads API callsCreate a campaign with a budget, schedule, and bid strategy. The campaign starts indraftstatus until you explicitly launch it.
import { AdsClient } from '@eventzr/ads-client';
const adsClient = new AdsClient({
baseUrl: 'https://api.eventzr.com/ads/v1',
tenantId: '<your-tenant-id>',
accessToken: accessToken,
});
const campaign = await adsClient.campaigns.create({
name: 'Summer Event Promo 2026',
type: 'display',
budgetType: 'daily',
budgetAmount: 5000,
currency: 'USD',
startDate: '2026-06-01T00:00:00Z',
endDate: '2026-08-31T23:59:59Z',
bidStrategy: 'maximize_clicks',
});
console.log('Campaign created:', campaign.data.id);
// => cmp_xyz789Attach one or more creatives (banner images, native ads, or video) to your campaign. Creatives must be approved before they can be served.
const creative = await adsClient.creatives.create({
campaignId: campaign.data.id,
name: 'Hero Banner 1200x628',
type: 'image',
format: 'banner',
width: 1200,
height: 628,
imageUrl: 'https://cdn.yourcompany.com/ads/summer-banner.png',
headline: 'Discover Amazing Events This Summer',
callToAction: 'Book Now',
destinationUrl: 'https://yourcompany.com/events/summer',
});
console.log('Creative created:', creative.data.id);
// => crt_abc456Request an ad for a specific placement in your application. The ad serving engine selects the best-matching creative based on targeting, budget, and bid.
const adResponse = await adsClient.serve.requestAd({
placementId: 'homepage-banner',
format: 'banner',
width: 1200,
height: 628,
context: {
pageUrl: 'https://yoursite.com/',
category: 'events',
},
});
if (adResponse.data) {
const ad = adResponse.data;
// Render the ad in your UI
// ad.creativeUrl - image/video URL
// ad.headline - ad headline
// ad.clickUrl - click-through URL (tracked)
// ad.impressionUrl - fire this URL to track impression
}See the Ad Serving Integration Guide for detailed implementation patterns and placement formats.
Track conversion events (purchases, sign-ups, etc.) to measure campaign effectiveness and optimize for ROAS.
await adsClient.conversions.track({
campaignId: campaign.data.id,
eventType: 'purchase',
value: 49.99,
currency: 'USD',
orderId: 'order_12345',
metadata: {
productName: 'VIP Event Ticket',
quantity: 2,
},
});
// View campaign performance
const report = await adsClient.reports.getCampaignReport(
campaign.data.id,
{ dateRange: 'last_7_days' },
);
console.log('Impressions:', report.data.impressions);
console.log('Clicks:', report.data.clicks);
console.log('CTR:', report.data.ctr);
console.log('Conversions:', report.data.conversions);
console.log('ROAS:', report.data.roas);Once your campaign has at least one approved creative, launch it to start serving ads.
await adsClient.campaigns.launch(campaign.data.id);
// Campaign status changes from 'draft' -> 'active'
// Ads will begin serving based on your schedule and budget