Get started3 / 12

Quickstart

This walks one player through one offer on Test: your backend sends an event, the player sees the offer in your game, completes it, claims it, and your backend grants the reward. Examples use the Node.js and JavaScript SDKs. The other SDKs work the same way.

1. Get your credentials

Sign in to the dashboard and switch to Test at the top. Open Credentials and copy the Client ID and the API Key.

Test and Live are separate: each has its own credentials, data and webhooks. Build on Test.

2. Describe what your game gives away

Open Asset Library and add the currencies and items your game can grant, each with an id your backend knows, such as gold. Offers reward these, and conditions refer to them, by id.

3. Send events from your backend

Shell
npm install @pixels-online/pixels-analytics-node-sdk
TypeScript
import PixelsAnalytics from '@pixels-online/pixels-analytics-node-sdk';

const analytics = new PixelsAnalytics({
  apiKey: process.env.STACKED_API_KEY,
  clientId: process.env.STACKED_CLIENT_ID,
  env: 'test',
});

// When a player signs in
analytics.signIn('player-1', { username: 'ada' });

// When a player spends currency
analytics.spendCurrency('player-1', {
  currency_id: 'gold',
  currency_amount: 100,
  to_kind: 'store',
  to_id: 'starter-shop',
});

Calls return at once. The SDK sends events in batches every two seconds, so call await analytics.flush() before a short script exits. Events lists everything you can send.

4. Create an offer

Open Offers and create one:

  • Surfacing conditions: none, so every player gets it.
  • Completion condition: spend 100 gold.
  • Reward: something from your asset library.

Save it, then switch it on: a new offer starts disabled. Offers explains every part.

5. Receive the reward webhook

Open Webhooks, add your backend's URL and subscribe it to user.gain_rewards. Copy the signing secret into your backend, and grant what the webhook says:

TypeScript
app.post('/stacked/rewards', express.raw({ type: 'application/json' }), async (req, res) => {
  const reward = webhook.verify(req.body, {
    'svix-id': req.header('svix-id'),
    'svix-timestamp': req.header('svix-timestamp'),
    'svix-signature': req.header('svix-signature'),
  });
  await grantOnce(reward.dedupeId, () => giveRewards(reward.playerId, reward.rewards));
  res.status(204).end();
});

Reward webhooks has the full handler. Do this before the first claim: a claim fails while webhooks are not set up.

6. Show offers in your game

A game client never holds the API key. Add an endpoint to your backend that signs a token for the signed-in player:

TypeScript
app.post('/api/stacked-token', async (req, res) => {
  const token = await analytics.signJwt({ playerId: req.user.id });
  res.json({ token });
});

Then start the client SDK with it:

Shell
npm install @pixels-online/pixels-client-js-sdk
TypeScript
import { OfferwallClient } from '@pixels-online/pixels-client-js-sdk';

const client = new OfferwallClient({
  env: 'test',
  tokenProvider: async () => {
    const response = await fetch('/api/stacked-token', { method: 'POST' });
    return (await response.json()).token;
  },
  fallbackRewardImage: 'https://your-game.example/reward.png',
});

await client.initialize();
const offers = client.getOffers();

initialize fetches the player's offers and opens the realtime connection. Draw offers however suits your game: each has a name, description, image, rewards, status and progress.

7. Complete and claim

The offer counts progress from the moment it surfaced for the player, so spend the gold after step 6. Send the spendCurrency event from step 3 again, then refresh:

TypeScript
await client.refreshOffersAndPlayer();

const offer = client.getOffers().find((o) => o.status === 'claimable');
if (offer) await client.claimReward(offer.instanceId);

Stacked marks the offer claimed and sends the webhook. Your backend grants the reward.

8. Go live

  • Switch to Live in the dashboard and copy the Live credentials. Set env: 'live' in both SDKs.
  • Add your Live webhook endpoint. It has its own signing secret.
  • Create your offers on Live. Nothing carries over from Test by itself.

Where next

ToRead
Understand the pieces before building moreCore concepts
Target offers and track different actionsOffers
Run a timed event with milestones and dailiesLive Ops
Rank players and pay the winnersLeaderboards
Let an AI agent set all of this upMCP server