Piqki Performance Reporting System

Automated Weekly Brief Spec β€” Last updated: 2026-02-21


Summary

The Piqki Performance Reporting System is an automated Monday morning brief that pulls data from GA4, Klaviyo, GoAffPro, and Shopify into a single Telegram message for Gin. It replaces manual data pulls and ensures Gin sees the right metrics every week without logging into anything.


1. Weekly Brief Format

The Monday morning Telegram message will look exactly like this:


πŸ“Š PIQKI WEEKLY PERFORMANCE β€” [DATE]

MER: [X.X]x (Revenue Γ· Ad Spend) β†’ Target: β‰₯2.0x | Last week: [X.X]x

Contribution Margin: $[XX.XX]/order β†’ Revenue - COGS - Ad Spend Γ· Orders

πŸ† Top Performer:

πŸ“§ Klaviyo Revenue:

🀝 Affiliate Revenue:

πŸ“¬ Email List:

⚑ Kill/Scale Flags:

πŸ’‘ MAX'S RECOMMENDATION: [One sentence β€” e.g., "Double budget on Concept C, kill Concept A, continue testing Concept B."]


2. Data Sources + How to Pull Each

2.1 GA4 (Google Analytics 4)

What we need:

API Endpoint:

Field names:

Time window: Last 7 days (dynamic, calculated at runtime)

Confidence: High β€” GA4 Data API is well-documented and stable.

Reference: Google Analytics 4 Ecommerce measurement (developers.google.com/analytics/devguides/collection/ga4/ecommerce)


2.2 Klaviyo (Email Marketing)

What we need:

API Endpoints:

List Size + Growth:

Revenue Attribution:

Flow vs. Campaign breakdown:

Confidence: Medium β€” Klaviyo's API is comprehensive but revenue attribution requires the correct metric ID. Must find the "Placed Order" metric ID in the specific Piqki Klaviyo account.

Reference: Klaviyo Developer Docs β€” Metrics API, Export API (developers.klaviyo.com)


2.3 GoAffPro (Affiliate Program)

What we need:

API Endpoint:

Specific endpoints:

Field names:

Date filter: Query parameters start_date and end_date (format: YYYY-MM-DD)

Confidence: Medium β€” GoAffPro API exists but documentation is limited. The Swagger UI (api.goaffpro.com/docs/admin/) provides the most reliable endpoint list.

Reference: GoAffPro API Documentation (docs.goaffpro.com), Swagger UI (api.goaffpro.com/docs/admin/)


2.4 Shopify (Orders + Revenue)

What we need:

API Endpoint:

Query parameters:

Field names:

Calculations:

Confidence: High β€” Shopify API is mature, well-documented, and stable.

Reference: Shopify Admin API β€” Orders (shopify.dev/docs/api/admin-graphql/latest/queries/orders)


2.5 Meta Ads (via GA4 or Meta)

What we need:

Options:

Option A β€” GA4 (recommended):

Option B β€” Meta Ads API:

Confidence: Medium β€” Meta API requires a Meta app with ads_read permission. Gin must grant access.

Reference: Meta Marketing API β€” Insights Edge (developers.facebook.com/docs/marketing-api/insights)


3. OpenClaw Skill Spec

3.1 Skill Structure

skills/
β”œβ”€β”€ piqki-weekly-brief/
β”‚   β”œβ”€β”€ SKILL.md          # This file
β”‚   β”œβ”€β”€ fetch_data.py      # API calls to all platforms
β”‚   β”œβ”€β”€ format_message.py # Telegram message formatting
β”‚   └── skill.yaml        # OpenClaw skill definition

3.2 Cron Job Payload

skill: piqki-weekly-brief
trigger:
  type: cron
  schedule: "0 9 * * 1"  # Every Monday at 9am PT
  timezone: America/Los_Angeles

env:
  GA4_PROPERTY_ID: [env var]
  GA4_CLIENT_EMAIL: [env var]
  GA4_PRIVATE_KEY: [env var]
  KLAVIYO_PRIVATE_API_KEY: [env var]
  GOAFFPRO_API_KEY: [env var]
  SHOPIFY_STORE: piqki
  SHOPIFY_ACCESS_TOKEN: [env var]
  TELEGRAM_CHAT_ID: [env var]
  TELEGRAM_BOT_TOKEN: [env var]

3.3 Execution Flow

  1. Calculate date range: Today - 7 days
  2. Fetch GA4 data: Revenue, sessions, conversions
  3. Fetch Klaviyo data: List size, revenue attribution
  4. Fetch GoAffPro data: Affiliate sales, active count
  5. Fetch Shopify data: Total orders, revenue, AOV
  6. Fetch Meta ads: Spend, CTR per creative
  7. Calculate derived metrics:
  8. Format Telegram message: Using format in Section 1
  9. Send message: Via Telegram Bot API
  10. Log results: Store in workspace for historical reference

3.4 Error Handling

Scenario Response
One API fails Send partial brief with available data. Note: "⚠️ [Platform] unavailable β€” using [date] data"
All APIs fail Send error message to Telegram: "❌ Weekly brief failed β€” APIs unreachable. Check manually."
Partial data (no sales) Send: "⚠️ No sales data this week β€” possible tracking issue"
Rate limit hit Retry once after 30s. If still failing, skip and note in message.

4. Setup Requirements

4.1 API Credentials Needed

Platform Credential How to Get
GA4 Service Account Google Cloud Console β†’ IAM β†’ Create Service Account β†’ Generate JSON key
GA4 Property ID GA4 Admin β†’ Property Settings β†’ Property ID
Klaviyo Private API Key Klaviyo β†’ Account β†’ API Keys β†’ Create Private API Key
GoAffPro API Key GoAffPro Admin β†’ Settings β†’ Advanced β†’ Access Tokens β†’ New API Key
Shopify Admin API Access Token Shopify Admin β†’ Settings β†’ Apps β†’ Develop Apps β†’ Create App β†’ Configure Admin API scopes
Meta Ad Account ID Meta Business Manager β†’ Ad Accounts
Meta Access Token Meta for Developers β†’ Marketing API β†’ Access Token (or use long-lived token)
Telegram Bot Token @BotFather on Telegram β†’ /newbot
Telegram Chat ID @userinfobot or forward message to @my_id_bot

4.2 Permissions Required

GA4:

Klaviyo:

GoAffPro:

Shopify:

Meta:

4.3 What Gin Needs to Do (One-Time Setup)

  1. Create GA4 Service Account:

  2. Generate Klaviyo API Key:

  3. Generate GoAffPro API Key:

  4. Set up Shopify Admin App:

  5. Set up Telegram Bot:

  6. Add environment variables to OpenClaw:


5. Gin Decides Flags

The following decisions are needed before this system can be fully built:

5.1 Kill/Scale Thresholds

The spec uses these defaults from the Creative Testing System:

Gin decides:

5.2 Contribution Margin Calculation

Current formula: (Revenue - COGS - Ad Spend) Γ· Orders

Gin decides:

5.3 Meta Ads Integration

Two options:

Gin decides:

5.4 Missing Data Fallback

If any API is unavailable:

Gin decides:


6. Metrics Definitions

Metric Formula Source
MER Total Revenue Γ· Total Ad Spend Shopify + Meta
Contribution Margin/order (Revenue - COGS - Ad Spend) Γ· Orders Shopify + Meta + Est. COGS
Klaviyo Revenue Attributed revenue (7 days) Klaviyo API
Klaviyo % of Total Klaviyo Revenue Γ· Total Revenue Calculated
Affiliate Revenue GoAffPro sales (7 days) GoAffPro API
Email List Size Total subscribers Klaviyo API
Weekly List Growth (Current - 7 days ago) Γ· 7 days ago Klaviyo API
Top Creative Highest CTR at β‰₯$50 spend Meta/GA4
Kill Flag CTR <0.8% after $50 spend Meta
Scale Flag CTR >2.5% Meta

7. Sources & Validation

[1] GA4 Ecommerce API β€” revenue tracking Source: Google Analytics 4 Developer Documentation (developers.google.com/analytics/devguides/collection/ga4/ecommerce) Status: High confidence β€” Official Google documentation. Standard ecommerce implementation.

[2] Klaviyo Metrics API β€” revenue attribution Source: Klaviyo Community discussions + Developer Docs Status: Medium confidence β€” API exists and is documented. Requires finding specific metric IDs in Piqki account. Use /export endpoint with "Placed Order" metric.

[3] GoAffPro API β€” affiliate sales Source: GoAffPro documentation (docs.goaffpro.com) + Swagger UI (api.goaffpro.com/docs/admin/) Status: Medium confidence β€” API exists. Documentation is sparse. Swagger UI is the most reliable reference.

[4] Shopify Orders API Source: Shopify Admin API Documentation (shopify.dev/docs/api/admin-graphql/latest/queries/orders) Status: High confidence β€” Mature, well-documented API.

[5] MER (Marketing Efficiency Ratio) Source: DTC practitioner methodology β€” popularized by Taylor Holiday / Common Thread Collective Status: Industry standard β€” Widely used in DTC circles. Target β‰₯2.0 is directional; actual target depends on margin structure.

[6] Kill/Scale thresholds Source: Piqki Creative Testing System (piqki-creative-testing-system.md) Status: Internal standard β€” Based on DTC best practices. $50 minimum spend threshold ensures statistical significance.


8. Implementation Notes


9. Open Questions

  1. Shopify access: Gin has not yet accepted the Shopify invite. System cannot fetch order data until access is granted.
  2. Meta ads access: No Meta Business access yet (see index.html "Meta Business Invite" pending).
  3. GoAffPro access: No GoAffPro admin access yet (see index.html "GoAffPro Access" pending).
  4. AOV data: Should we include average order value trend? (Added to brief if useful.)
  5. Week-over-week comparison: Should we show % change vs. previous week for each metric?

Document ends. Next step: Build the OpenClaw skill once Gin approves setup and provides credentials.