PelekaPeleka Developers
Guides

Building custom analytics

Compose the analytics endpoints into your own reporting view instead of screen-scraping the dashboard.

The dashboard's analytics tabs are all backed by the same endpoints available here. If you want the numbers in your own BI tool, a Slack digest, or a client-facing report, you're pulling from the same source, not an approximation of it.

Date ranges

Every analytics endpoint takes startDate and endDate as ISO 8601 query params. Neither has a default, so both are required on every call:

curl "https://api.peleka.io/api/v1/analytics/overview?startDate=2026-07-01&endDate=2026-08-01" \
  -H "X-API-Key: pel_live_..."

There's no relative-range shorthand like last_30_days; compute the actual dates on your side before making the call.

Start with overview

GET /analytics/overview is the one endpoint that pulls a bit of everything: contacts, broadcasts, engagement, automations, forms, in a single response. It's the right first call if you're building a dashboard home screen and don't want five separate requests before anything renders:

{
  "data": {
    "contacts": { "total": 21200, "subscribed": 18400, "growthRate": 1.8 },
    "broadcasts": { "sent": 186, "avgDeliveryRate": 99.1 },
    "emailEngagement": { "openRate": 45.8, "clickRate": 11.8 },
    "automations": { "totalEnrolled": 38400, "avgCompletionRate": 64.6 },
    "forms": { "totalSubmissions": 52840, "overallConversionRate": 28.7 }
  }
}

From there, drill into whichever section needs more detail. Each top-level key in overview has a matching resource-specific endpoint with far more fields than the summary carries.

Digging into one resource

Say you're building a broadcasts performance page. GET /analytics/broadcasts gets you the section-level summary shown above, but there's a longer list of narrower endpoints once you need specifics: /analytics/broadcasts/stats, /engagement, /funnel, /revenue, /top-links, /best-days, /best-time, /clicks-by-device, and a few more. Each one is scoped tightly enough that you're not parsing a giant object to find the three numbers you actually need.

The same pattern repeats for contacts (/analytics/contacts/*), automations (/analytics/automations/*), and forms (/analytics/forms/*): a general summary endpoint, plus a set of specific ones underneath it. Check the API reference for the full list under each resource; there's no need to memorize them, just know the pattern so you can find the right one.

Revenue attribution

If you've connected Shopify or WooCommerce, GET /analytics/broadcasts/revenue attributes order revenue back to the broadcast that likely drove it, based on click activity in the attribution window. Without a connected store, this endpoint still responds — it just returns zeros rather than an error, so you don't need to special-case workspaces without e-commerce integration in your own code.

Building a weekly digest

A common use case: pull the previous 7 days of overview stats and post them somewhere on a schedule.

async function weeklyDigest() {
  const end = new Date();
  const start = new Date(end.getTime() - 7 * 24 * 60 * 60 * 1000);

  const res = await fetch(
    `https://api.peleka.io/api/v1/analytics/overview?startDate=${start.toISOString()}&endDate=${end.toISOString()}`,
    { headers: { 'X-API-Key': process.env.PELEKA_API_KEY } },
  );
  const { data } = await res.json();

  return `This week: ${data.contacts.total} contacts (+${data.contacts.growthRate}%), ` +
    `${data.broadcasts.sent} broadcasts sent, ${data.emailEngagement.openRate}% avg open rate.`;
}

Run it on a cron, pipe the string into Slack, email, wherever your team actually looks. A read-scoped API key is all this needs; nothing here writes anything back.

On this page