Segment Integrations | OpsBlu Docs

Segment Integrations

Integrations linking Segment with ad platforms, CMS tooling, and downstream analytics.

Integration Inventory

Segment as Customer Data Platform

Segment acts as a central hub for collecting, transforming, and routing customer data to 300+ destinations:

Analytics & Product

Marketing & Advertising

CRM & Sales

  • Salesforce - Lead management and attribution
  • HubSpot - Marketing automation
  • Marketo - Campaign orchestration
  • Pipedrive - Sales pipeline
  • Close - Sales engagement
  • Copper - Relationship management

Email & Messaging

  • SendGrid - Transactional email
  • Mailchimp - Email marketing
  • Braze - Multi-channel messaging
  • Iterable - Growth marketing
  • Customer.io - Behavioral emails
  • Intercom - Customer communication

Data Warehouses

Reverse ETL (Segment Connections)

  • Census - Warehouse-first activation
  • Hightouch - Data activation platform
  • Polytomic - Operational analytics

Segment Platform Components

Sources

  • JavaScript (Analytics.js) - Web tracking
  • Mobile SDKs (iOS, Android) - App tracking
  • Server-side libraries (Node, Python, Go, Java, Ruby, PHP)
  • Cloud apps (Stripe, Zendesk, Shopify)
  • Reverse ETL sources

Destinations

  • Streaming destinations - Real-time data forwarding
  • Cloud-mode destinations - Server-side routing
  • Device-mode destinations - Client-side integration
  • Warehouse destinations - Data storage

Protocols

  • Schema validation
  • Event blocking and filtering
  • Transformations
  • PII filtering
  • Data quality monitoring

Licensing & Feature Access

Segment Plan Tiers

Feature Free Team Business
MTUs (Monthly Tracked Users) 1,000 10,000+ Custom
Destinations 2 Unlimited Unlimited
Sources Unlimited Unlimited Unlimited
Protocols (schema control) - Limited Full
Transformations - Basic Advanced
Replay - 3 months 12 months
Privacy portal Basic Standard Enterprise

Implementation Playbooks

JavaScript Source Setup

Implement Segment's Analytics.js for web tracking:

Installation

<!-- Add Segment snippet to <head> -->
<script>
  !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src="https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js";var n=document.getElementsByElement("script")[0];n.parentNode.insertBefore(t,n);analytics._loadOptions=e};analytics._writeKey="YOUR_WRITE_KEY";analytics.SNIPPET_VERSION="4.15.3";
  analytics.load("YOUR_WRITE_KEY");
  analytics.page();
  }}();
</script>

Identify Users

// Identify logged-in users
analytics.identify('user_12345', {
  name: 'Jane Smith',
  email: 'jane@example.com',
  plan: 'Enterprise',
  company: 'Acme Corp',
  createdAt: '2025-01-15T00:00:00Z'
});

// Track anonymous users (automatic)
// Segment automatically assigns anonymousId

Track Events

// Page tracking (automatic with analytics.page())
analytics.page('Product', 'Product Details', {
  product_id: 'prod_12345',
  category: 'Electronics',
  price: 299.99
});

// Custom event tracking
analytics.track('Product Added', {
  product_id: 'prod_12345',
  product_name: 'Wireless Headphones',
  price: 299.99,
  quantity: 1,
  currency: 'USD'
});

// E-commerce tracking
analytics.track('Order Completed', {
  order_id: 'ORD-12345',
  total: 449.97,
  revenue: 399.97,
  shipping: 20.00,
  tax: 30.00,
  discount: 50.00,
  currency: 'USD',
  products: [
    {
      product_id: 'prod_12345',
      sku: 'WH-001',
      name: 'Wireless Headphones',
      price: 299.99,
      quantity: 1,
      category: 'Electronics'
    }
  ]
});

Server-Side Implementation

Track events from your backend:

Node.js Example

const Analytics = require('analytics-node');
const analytics = new Analytics('YOUR_WRITE_KEY');

// Identify user server-side
analytics.identify({
  userId: 'user_12345',
  traits: {
    email: 'user@example.com',
    name: 'Jane Smith',
    plan: 'Pro',
    company: 'Acme Corp'
  }
});

// Track backend events
analytics.track({
  userId: 'user_12345',
  event: 'API Call Made',
  properties: {
    endpoint: '/api/v1/users',
    method: 'POST',
    status_code: 201,
    response_time_ms: 145
  }
});

// Track group (account/organization)
analytics.group({
  userId: 'user_12345',
  groupId: 'company_789',
  traits: {
    name: 'Acme Corp',
    plan: 'Enterprise',
    employees: 250,
    industry: 'Technology'
  }
});

// Flush events before process exit
process.on('exit', () => {
  analytics.flush();
});

Python Example

import analytics

analytics.write_key = 'YOUR_WRITE_KEY'

# Identify user
analytics.identify('user_12345', {
    'email': 'user@example.com',
    'name': 'Jane Smith',
    'plan': 'Pro',
    'company': 'Acme Corp'
})

# Track event
analytics.track('user_12345', 'File Uploaded', {
    'file_name': 'report.pdf',
    'file_size_bytes': 2048576,
    'file_type': 'application/pdf'
})

# Flush before exit
import atexit
atexit.register(analytics.flush)

Destination Configuration

Route Segment data to downstream tools:

Google Analytics Setup

  1. In Segment workspace, navigate to Destinations
  2. Click "Add Destination" > Search for "Google Analytics"
  3. Select the source to connect (e.g., JavaScript website)
  4. Enter Google Analytics Tracking ID (UA-XXXXX-X or G-XXXXXX)
  5. Configure mappings:
    • Map Segment events to GA events
    • Set custom dimensions
    • Configure e-commerce tracking
  6. Enable destination and test

Mapping Configuration

// Segment event automatically maps to GA
analytics.track('Product Viewed', {
  product_id: 'prod_123',
  name: 'Wireless Mouse',
  price: 29.99,
  category: 'Electronics'
});

// This sends to Google Analytics as:
// Event Category: 'All'
// Event Action: 'Product Viewed'
// Event Label: undefined
// Event Value: undefined

// Or configure custom mapping in Segment UI:
// GA Event Category: properties.category → 'Electronics'
// GA Event Action: event name → 'Product Viewed'
// GA Event Label: properties.name → 'Wireless Mouse'
// GA Event Value: properties.price → 29.99

Salesforce Integration

  1. Add Salesforce destination in Segment
  2. Authenticate with Salesforce OAuth
  3. Map Segment events to Salesforce objects:
    • identify calls → Lead/Contact creation
    • track calls → Task/Activity logging
    • group calls → Account updates
  4. Configure field mappings
  5. Set up lead assignment rules

Protocols (Schema Management)

Enforce data quality with Segment Protocols:

Schema Definition

# tracking_plan.yaml
events:
  - name: "Order Completed"
    description: "User completed a purchase"
    properties:
      - name: "order_id"
        type: "string"
        required: true
        pattern: "^ORD-[0-9]{5}$"
      - name: "total"
        type: "number"
        required: true
        minimum: 0
      - name: "currency"
        type: "string"
        required: true
        enum: ["USD", "EUR", "GBP"]
      - name: "products"
        type: "array"
        required: true
        items:
          type: "object"
          properties:
            - name: "product_id"
              type: "string"
              required: true

Violation Handling

// Valid event - passes validation
analytics.track('Order Completed', {
  order_id: 'ORD-12345',
  total: 299.99,
  currency: 'USD',
  products: [{
    product_id: 'prod_123',
    name: 'Widget',
    price: 299.99
  }]
});

// Invalid event - blocked or flagged
analytics.track('Order Completed', {
  order_id: '12345',  // Invalid format
  total: -10,  // Invalid value
  currency: 'JPY',  // Not in enum
  // products missing - required field
});
// This event is blocked/flagged based on Protocols settings

Data Activation

Audience Sync & Personalization

Create audiences in Segment and sync to marketing platforms:

Audience Builder

-- SQL-based audience definition in Segment
SELECT user_id
FROM tracks
WHERE event = 'Product Viewed'
  AND properties.price > 100
  AND timestamp > CURRENT_DATE - INTERVAL '7 days'
EXCEPT
SELECT user_id
FROM tracks
WHERE event = 'Order Completed'
  AND timestamp > CURRENT_DATE - INTERVAL '7 days'

Multi-Destination Sync

Configure audience to sync to multiple platforms simultaneously:

  • Google Ads - Remarketing
  • Facebook Ads - Custom Audience
  • Braze - Targeted messaging
  • Salesforce - Lead nurturing
  • Iterable - Email campaigns

Reverse ETL Integration

Import warehouse data back into Segment:

Census + Segment

-- Define sync in Census
-- Source: Snowflake query
SELECT
  user_id,
  email,
  lifetime_value,
  churn_risk_score,
  preferred_category,
  last_purchase_date
FROM analytics.customer_360
WHERE churn_risk_score > 0.7
  AND last_purchase_date < CURRENT_DATE - 30

-- Destination: Segment (as identify calls)
-- Maps to analytics.identify() automatically

Real-Time Personalization

Use Segment's Engage (Twilio Segment Personas) for real-time personalization:

Computed Traits

// Computed trait: total_purchases (calculated in Segment)
// Available in all destinations automatically

analytics.identify('user_12345');
// Segment adds computed trait:
// {
//   userId: 'user_12345',
//   traits: {
//     total_purchases: 15,  // Computed
//     lifetime_value: 1499.85,  // Computed
//     first_purchase_date: '2024-03-15'  // Computed
//   }
// }

Compliance & Security

Privacy & Data Governance

GDPR Compliance

// User consent management
if (userConsent.analytics) {
  analytics.load('YOUR_WRITE_KEY');
} else {
  // Don't load Segment
}

// Delete user data (GDPR right to erasure)
// Use Segment Privacy Portal or API
const deleteUser = async (userId) => {
  const response = await fetch('https://platform.segmentapis.com/v1beta/workspaces/WORKSPACE_ID/regulations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      regulation_type: 'DELETE',
      attributes: {
        userId: userId
      }
    })
  });

  return response.json();
};

PII Filtering

// Configure PII filtering in Segment UI
// Or use client-side filtering
analytics.addSourceMiddleware(({ payload, next }) => {
  // Remove email from properties
  if (payload.obj.properties && payload.obj.properties.email) {
    delete payload.obj.properties.email;
  }

  // Hash user ID
  if (payload.obj.userId) {
    payload.obj.userId = hashUserId(payload.obj.userId);
  }

  next(payload);
});

function hashUserId(userId) {
  // Implement hashing logic
  return btoa(userId);  // Simple example
}

Access Control

Role-Based Permissions

  • Workspace Owner - Full access, billing
  • Workspace Admin - All features except billing
  • Source Admin - Manage specific sources
  • Read-Only - View analytics and debugger

Advanced Integration Opportunities

Protocols Enforcement: Use Segment Protocols to enforce your tracking plan schema across all sources. Violations can be blocked, flagged, or allowed — start permissive during development, then tighten for production.

Replay and Backfill: When adding new destinations, use Segment Replay to backfill historical data from your warehouse to the new destination. This eliminates the "cold start" problem where new tools have no historical data.

Functions: Segment Functions let you transform events in-flight using custom JavaScript. Use destination functions to reshape data for destinations with non-standard schemas, or source functions to ingest data from custom APIs.