Cdp segment rudderstack mparticle

From CraftOS-dev/craftbot-agent-bundles · View interactive version

Cdp segment rudderstack mparticle is an AI agent skill from the GitHub repository CraftOS-dev/craftbot-agent-bundles. Source: Segment Tracking Plan docs + RudderStack OSS docs + genesys CDP alternatives + mParticle mobile-first

How to use this skill

Skill file

<!--

Source: Segment Tracking Plan docs + RudderStack OSS docs + genesys CDP alternatives + mParticle mobile-first

-->

CDP Setup — Segment / RudderStack / mParticle SKILL

Choose CDP, design event taxonomy (Object-Action past-tense), write tracking plan in Notion. Foundation for every downstream tool (analytics, lifecycle, attribution, reverse-ETL).

When to use

Trigger phrases:

Pair: reverse-etl-hightouch-census-growth (downstream activation), behavioral-cohort-design (cohorts on top of events), cli-anything (CDP API for instrumentation).

Setup

export SEGMENT_WRITE_KEY="<key>"
export RUDDERSTACK_WRITE_KEY="<key>"
export RUDDERSTACK_DATA_PLANE_URL="https://..."
export MPARTICLE_API_KEY="<key>"
export MPARTICLE_API_SECRET="<secret>"
export HIGHTOUCH_CDP_TOKEN="<token>"
export TEALIUM_TOKEN="<token>"
export NOTION_TOKEN="ntn_..."   # tracking plan host

Platform decision matrix

| CDP | Cost (2026) | Best when | Integrations | Warehouse-native |

|---|---|---|---|---|

| Segment | $0-50K/yr (tiered) | Default, broad needs | 350+ | Via Reverse-ETL add-on |

| RudderStack | OSS free / $0-9K cloud | Cost-sensitive; warehouse-first | 200+ | Yes, native |

| mParticle | Custom enterprise | Mobile-first orgs | 350+ | Add-on |

| Hightouch CDP | Custom | Composable; warehouse-as-CDP | 150+ destinations | Yes, native |

| Tealium | Enterprise | 1,300+ integrations | 1,300+ | Yes |

| Snowplow (OSS) | OSS free / $0-20K | Custom schema; warehouse-first | Custom | Yes, native |

Selection logic

Q1: Already in warehouse-native modern stack?
   yes → RudderStack OSS / Hightouch CDP / Snowplow
   no  → Segment / mParticle / Tealium

Q2: Mobile-first?
   yes → mParticle (best mobile SDKs) / Segment
   no  → all viable

Q3: Cost sensitivity?
   bootstrapped → RudderStack OSS / Snowplow OSS
   mid           → Segment Team / Hightouch CDP
   enterprise   → Tealium / mParticle

Q4: Integration depth?
   broad → Tealium (1,300+) / Segment (350+)
   moderate → RudderStack / Hightouch

Event taxonomy — the canonical rules

1. Object-Action format (past-tense): "Subscription Started"
   - NOT: "subscribe" or "subscription" or "createSubscription"
2. Title-Case
3. No abbreviations
4. Same event name across platforms (web, iOS, Android, server)
5. Properties = noun:value pairs ("plan_tier": "Pro")
6. Standard properties on every event:
   - timestamp (auto)
   - user_id / anonymous_id (auto via Identify)
   - context (page URL, referrer, UTM, device)
   - revenue, currency (if commerce)

Examples

GOOD:
  "Account Created"       (props: signup_source, plan_tier)
  "Document Shared"       (props: document_id, share_method, recipient_count)
  "Subscription Started"  (props: plan, price, currency, billing_cycle)
  "Payment Failed"        (props: error_code, attempted_amount)

BAD:
  "page_view"             (snake_case + ambiguous)
  "user_signup"           (snake_case)
  "subscribed"            (no object)
  "Subscription"          (no action)
  "click_button"          (too generic; what button?)

Common recipes

Recipe 1: Segment Identify + Track (web JS)

// Identify
analytics.identify("user_abc123", {
  email: "user@acme.com",
  first_name: "Jane",
  company: "Acme Corp",
  plan_tier: "Pro",
  created_at: "2026-01-15T10:00:00Z"
});

// Track
analytics.track("Document Shared", {
  document_id: "doc_456",
  share_method: "email",
  recipient_count: 3,
  workspace_id: "ws_789"
});

// Group (B2B)
analytics.group("acme_co_id", {
  name: "Acme Corp",
  industry: "SaaS",
  employees: 200,
  plan_tier: "Pro"
});

Recipe 2: Segment server-side via curl

curl -X POST "https://api.segment.io/v1/track" \
  -u "$SEGMENT_WRITE_KEY:" \
  -d '{
    "userId": "user_abc123",
    "event": "Subscription Started",
    "properties": {
      "plan": "Pro",
      "price": 49,
      "currency": "USD",
      "billing_cycle": "monthly"
    },
    "context": {"ip": "1.2.3.4"}
  }'

Recipe 3: RudderStack (drop-in Segment replacement)

// Same JS API as Segment
rudderanalytics.identify("user_abc123", {email: "user@acme.com"});
rudderanalytics.track("Document Shared", {...});
curl -X POST "${RUDDERSTACK_DATA_PLANE_URL}/v1/track" \
  -u "$RUDDERSTACK_WRITE_KEY:" \
  -d '{"userId": "user_abc123", "event": "Subscription Started", "properties": {...}}'

Recipe 4: mParticle mobile (iOS Swift)

import mParticle_Apple_SDK

// Init
MParticle.sharedInstance().start(withOptions: MParticleOptions(key: API_KEY, secret: API_SECRET))

// Identify
let request = MParticleUser.identifyRequest()
request.email = "user@acme.com"
MParticle.sharedInstance().identity.identify(request, completion: nil)

// Track
let event = MPEvent(name: "Document Shared", type: .other)
event.customAttributes = ["document_id": "doc_456", "share_method": "email"]
MParticle.sharedInstance().logEvent(event)

Recipe 5: Tracking plan in Notion (the deliverable)

# Event Tracking Plan — Acme Corp

| Event | Triggered When | Required Properties | Source(s) | Status | Owner |
|---|---|---|---|---|---|
| Account Created | After email verification | email, plan_tier, signup_source | web, mobile | Live | Eng + PM |
| Subscription Started | Stripe webhook on success | plan, price, currency, billing_cycle | server | Live | Eng |
| Document Created | On first save | document_id, type, workspace_id | web, mobile | Live | PM |
| Document Shared | On share button click | document_id, share_method, recipient_count | web | Live | PM |
| Limit Approached | Hourly cron check | limit_type, usage_pct | server | Beta | Eng |
| Activation Event Hit | When 3 docs created | n_docs | server | Live | PM |

Recipe 6: Validation — Avo / Iteratively style

# Add a schema-validator before sending to CDP
EVENT_SCHEMA = {
    "Document Shared": {
        "required": ["document_id", "share_method", "recipient_count"],
        "types": {
            "document_id": str,
            "share_method": str,
            "recipient_count": int
        }
    }
}

def track(event_name, props):
    schema = EVENT_SCHEMA.get(event_name)
    if not schema:
        raise ValueError(f"Unknown event: {event_name}")
    for req in schema["required"]:
        if req not in props:
            raise ValueError(f"Missing required prop: {req}")
        if not isinstance(props[req], schema["types"][req]):
            raise TypeError(f"Wrong type for {req}")
    # ... fire to CDP

Recipe 7: Identity stitching (anonymous → identified)

// Pre-signup (anonymous)
analytics.track("Pricing Page Viewed");  // tied to anonymous_id

// On signup
analytics.identify("user_abc123", {email});
// Segment automatically merges anonymous_id → user_id history

// Verify in PostHog / Amplitude: prior anon events now attributed to user_abc123

Recipe 8: Destination routing

Segment (or RudderStack) destination configuration:

Event "Subscription Started" → routes to:
  - PostHog (analytics)
  - Amplitude (analytics)
  - Stripe (already there)
  - Customer.io (lifecycle)
  - HubSpot (CRM)
  - Slack (#sales channel)

Event "Document Shared" → routes to:
  - PostHog
  - Mixpanel
  - Heap

Configure routing rules per event in Segment / RudderStack UI.

Recipe 9: Audit + dedupe events

-- In warehouse, find dup events
SELECT
  event_name,
  user_id,
  timestamp,
  COUNT(*) AS occurrences
FROM cdp_events
WHERE created_at >= now() - INTERVAL 30 DAY
GROUP BY event_name, user_id, timestamp
HAVING COUNT(*) > 1
LIMIT 100

Common causes: client + server double-firing, retry on 5xx, browser back-button.

Fix: idempotency keys.

Recipe 10: PII handling

DO send to CDP:
  email (hashed for some destinations)
  user_id (internal)
  company name
  behavioral events
  device context

DON'T send to CDP:
  Full credit card number (PCI)
  SSN, government IDs
  Health info (HIPAA)
  Free-text comments (may contain PII)

Use Segment Privacy Controls or RudderStack PII transforms to redact in transit.

Recipe 11: Mobile-app event timing

Events fire even when offline → SDK buffers and sends on next online.

Order-of-arrival NOT guaranteed; events have client_timestamp + server_timestamp.

For activation/retention analysis, use client_timestamp (true event time).
For real-time triggers, use server_timestamp.

Examples

Example 1: B2B SaaS, no CDP yet, mid-budget

Decision: Segment Team tier ($0-50K/yr). Standard tooling, broad integrations, fastest setup.

Deliverables (Recipe 5):

Timeline: 4-6 weeks engineering work.

Example 2: Bootstrapped, warehouse-first, $0 budget

Decision: RudderStack OSS self-hosted + Postgres warehouse + PostHog.

Same tracking plan; runs on existing infra. No marginal CDP cost.

Example 3: Mobile-first social app

Decision: mParticle (best mobile SDKs).

Plus: iOS + Android tracking plan, server-side fallback for ad-blocked events.

Edge cases / gotchas

Sources

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.