Skip to content
adscapi

Lookalike seed

Pure transform: conversion events → a deduped, raw email list for audiences.sync(). Pipe your high-value converters in, sync the result, and the platforms build lookalikes from your best customers.

Signature

ts
import { audienceFromConversions } from 'adscapi';

const emails: string[] = audienceFromConversions(
  events: ConversionEvent[],
  opts?: {
    minValue?: number;  // only converters with event.value >= this
    events?: string[];  // only these event names (default: ['purchase'])
  },
);
// Returns RAW emails (normalized, deduped). sync hashes — do not pre-hash.

Options — FromConversionsOptions

FieldTypeNotes
minValuenumber?Only include converters whose event.value >= minValue. Events with no value are dropped when this is set
eventsstring[]?Only these canonical event names. Default: ['purchase']

Return

AudienceMembers — alias for string[], the raw emails list audiences.sync() / syncAudience consumes.

  • Reads event.user.email only (other match keys are ignored here)
  • Trims + lowercases
  • Dedupes with a Set
  • Never hashessyncAudience does that. Pre-hashing double-hashes and the addresses never match

Example

ts
import { createAdscapi, audienceFromConversions } from 'adscapi';

const ads = createAdscapi();

// Your warehouse / DB of past conversion events (ConversionEvent shape)
const pastPurchases = await loadConversions({ since: '2025-01-01' });

// High-value purchasers only
const seed = audienceFromConversions(pastPurchases, {
  minValue: 100,
  events: ['purchase'],
});
// → ['jane@example.com', 'bob@acme.com', …]  raw, lowercased, deduped

// Multi-event seed (purchasers + upgraded accounts)
const broader = audienceFromConversions(pastPurchases, {
  events: ['purchase', 'upgrade_clicked'],
});

// Pipe into audiences.sync — the SDK hashes on the way out
for (const platform of ['meta', 'google', 'tiktok'] as const) {
  const result = await ads.audiences.sync({
    platform,
    listName: 'lookalike-seed-100plus',
    emails: seed,
    consent: { adUserData: true, adPersonalization: true },
  });
  console.log(result);
}

Related