crosspromote
v0.3.1
Published
Framework-agnostic, minimal dependencies TypeScript package for implementing CrossPromote in your project.
Downloads
10
Maintainers
Readme
CrossPromote
CrossPromote package compatible with most JavaScript frameworks.
crosspromote is a package that allows you to display custom ads, referrals, and sponsored content inside your app, and to manage it through a unified dashboard.
Other implementations include:
Getting started
Create an account on CrossPromote and top it up.
Create your first ad, assign it to a an ad set, and create a new app.
Copy your app's identifier (it's visible under your app's name in the dashboard).
Add this package to your dependencies.
npm i crosspromote- Use the
CrossPromoteClientto retrieve ads:
// Create a new client.
const client = new CrossPromoteClient({
// Replace with your app's identifier from CrossPromote.
appId: "example.image",
});
// Fetch an ad.
const ad = await client.retrieve({
size: AdSize.W300H250,
match: AdMatch.preferredSize,
});
// One of the following: `image`, `metadata`, `empty`.
console.log(ad.type);
// An URL that redirects to a page specified in the console.
// This URL is a special variant that also tracks the number of clicks.
console.log(ad.targetUrl);
// Custom JSON payload specified in the console.
console.log(ad.payload);
// Properties available only for ads with type `image`.
if (ad.type === AdType.Image) {
console.log(ad.imageUrl);
console.log(ad.size);
}Additional information
- You can use predefined identifiers to test your app during development, and avoid incurring cost during testing. Use
example.imageas your app id to display a placeholder image, orexample.metadatafor metadata ad. - If there are any issues feel free to go to GitHub Issues and report a bug.
