agentsclimarketplace

Klaviyo core workflow b

Skill jeremylongshore/claude-code-plugins-plus-skills/plugins/saas-packs/klaviyo-pack/skills/klaviyo-core-workflow-b

425 plugins, 2,810 skills, 200 agents for Claude Code. Open-source marketplace at tonsofskills.com with the ccpi CLI package manager.

Install
npx -y skills add jeremylongshore/claude-code-plugins-plus-skills --skill klaviyo-core-workflow-b

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

Execute the Klaviyo secondary workflow: event tracking, segments, and campaigns. Use when you need to track customer events, query or size segments, build and send email campaigns, or inspect metric-triggered flows through the Klaviyo API. Trigger with phrases like "klaviyo events", "klaviyo segments", "klaviyo campaigns", "track klaviyo event", "klaviyo flow trigger".

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

5.9 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it

Klaviyo Core Workflow B -- Events, Segments & Campaigns

Overview

Secondary workflow: track customer events, query segments, create/send campaigns, and trigger metric-based flows via the klaviyo-api SDK. This page summarizes the five steps and their skeletons; the full copy-ready code lives in references/implementation.md and worked scenarios in references/examples.md.

Prerequisites

  • Completed klaviyo-core-workflow-a (profiles/lists set up)
  • API key scopes: events:write, segments:read, campaigns:read, campaigns:write, flows:read
  • klaviyo-api installed and KLAVIYO_PRIVATE_KEY set in the environment

Instructions

Open one session, then use the API class each step needs. Full parameter shapes for every step are in references/implementation.md.

import { ApiKeySession, EventsApi } from 'klaviyo-api';
const session = new ApiKeySession(process.env.KLAVIYO_PRIVATE_KEY!);
  1. Step 1 — Track server-side events. new EventsApi(session).createEvent(...). Include metric.data.attributes.name (auto-creates the metric), a profile, a value for revenue attribution, and a uniqueId for deduplication. Custom metrics trigger listening flows.
  2. Step 2 — Query events and metrics. MetricsApi.getMetrics() lists event types; EventsApi.getEvents({ sort: '-datetime', filter: 'equals(metric_id,"...")' }) reads recent events.
  3. Step 3 — Work with segments. SegmentsApi.getSegments() lists them, getSegmentProfiles() reads members, and getSegment({ additionalFieldsSegment: ['profile_count'] }) returns the size — check it before a send.
  4. Step 4 — Create an email campaign. Four ordered calls: create a template, create the campaign (with audiences.included/excluded), assign the template to the campaign message, then create the campaign-send-job. Sending before the template is assigned returns a 400.
  5. Step 5 — Query flows (read-only). FlowsApi.getFlows() lists flows; getFlowFlowActions({ id }) returns each flow's steps and their status.

Output

  • Event tracking returns an HTTP 202 Accepted acknowledgement (Klaviyo queues events asynchronously); the event appears in the profile's activity feed and fires any flow listening on that metric.
  • Metric/segment/flow queries return a body.data array of records with id and attributes (name, status, profileCount, etc.).
  • Campaign creation yields a campaign id; the send job queues the campaign, and Klaviyo reports delivery back in the app's campaign analytics.

Common Event Names for Flow Triggers

Event nameTypical triggerFlow type
Placed OrderPurchase completedPost-purchase / cross-sell
Started CheckoutCart createdAbandoned cart
Viewed ProductProduct page visitBrowse abandonment
Ordered ProductPer-item trackingProduct review request
Fulfilled OrderShipment sentShipping confirmation
Cancelled OrderOrder cancelledWin-back
Subscribed to ListEmail/SMS signupWelcome series
Custom EventAny API eventCustom automation

Error Handling

ErrorStatusCauseSolution
Invalid metric name400Empty or null metricAlways include metric.data.attributes.name
Segment not found404Wrong segment IDList segments with getSegments()
Campaign send failed400Missing template/audienceAssign template and set audience first
Duplicate eventN/ASame uniqueIdDeduplication built-in; safe to retry

Examples

Concrete, runnable scenarios are collected in references/examples.md:

  • Fire an abandoned-cart signal — track a Started Checkout event for a flow to pick up.
  • Size a segment before sending — read profileCount and refuse to send to an empty audience.
  • Create and send a campaign to a segment — the ordered template → campaign → assign → send-job chain.

A minimal event track:

import { EventsApi, EventEnum, ProfileEnum } from 'klaviyo-api';
const eventsApi = new EventsApi(session);

await eventsApi.createEvent({
  data: {
    type: EventEnum.Event,
    attributes: {
      metric: { data: { type: 'metric', attributes: { name: 'Placed Order' } } },
      profile: { data: { type: ProfileEnum.Profile, attributes: { email: '[email protected]' } } },
      value: 99.97,
      time: new Date().toISOString(),
      uniqueId: 'ORD-12345',
    },
  },
});

Resources

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.