What is Role-Based Targeting?
Role-based targeting is off by default. If you enable it, you can control which users see ads based on their subscription tier. For example, show ads only to free and basic users.
How to set it up
1. Go to Ad Display in your startup dashboard and set the allowed roles (e.g. free, basic).
2. Set ads.roleTargeting.enabled to true in your SDK config only when you want role filtering.
3. Ensure you call zc.identify() with the user's role before initializing the SDK.
src/zerocost.ts
// 1. Identify user role BEFORE init if you enable role targeting
zc.identify("user_123", { role: "free" });
// 2. Client-side mirror config
const zc = new ZerocostSDK({
// ...
ads: {
roleTargeting: {
enabled: true,
allowedRoles: ["free", "basic"]
}
}
});
zc.init();