Developers
API References
Data Subject Request API

Data Subject Request API Version 1 and 2

Data Subject Request API Version 3

Platform API

Key Management

Platform API Overview

Accounts

Apps

Audiences

Calculated Attributes

Data Points

Feeds

Field Transformations

Services

Users

Workspaces

Warehouse Sync API

Warehouse Sync API Overview

Warehouse Sync API Tutorial

Warehouse Sync API Reference

Data Mapping

Warehouse Sync SQL Reference

Warehouse Sync Troubleshooting Guide

ComposeID

Warehouse Sync API v2 Migration

Bulk Profile Deletion API Reference

Calculated Attributes Seeding API

Custom Access Roles API

Data Planning API

Group Identity API Reference

Pixel Service

Profile API

Events API

mParticle JSON Schema Reference

IDSync

Client SDKs
AMP

AMP SDK

Android

Initialization

Configuration

Network Security Configuration

Event Tracking

User Attributes

IDSync

Screen Events

Commerce Events

Location Tracking

Media

Kits

Application State and Session Management

Data Privacy Controls

Error Tracking

Opt Out

Push Notifications

WebView Integration

Logger

Preventing Blocked HTTP Traffic with CNAME

Workspace Switching

Linting Data Plans

Troubleshooting the Android SDK

API Reference

Upgrade to Version 5

Cordova

Cordova Plugin

Identity

Direct Url Routing

Direct URL Routing FAQ

Web

Android

iOS

Flutter

Getting Started

Usage

API Reference

React Native

Getting Started

Identity

iOS

Workspace Switching

Initialization

Configuration

Event Tracking

User Attributes

IDSync

Screen Tracking

Commerce Events

Location Tracking

Media

Kits

Application State and Session Management

Data Privacy Controls

Error Tracking

Opt Out

Push Notifications

Webview Integration

Upload Frequency

App Extensions

Preventing Blocked HTTP Traffic with CNAME

Linting Data Plans

Troubleshooting iOS SDK

Social Networks

iOS 14 Guide

iOS 15 FAQ

iOS 16 FAQ

iOS 17 FAQ

iOS 18 FAQ

API Reference

Upgrade to Version 7

Unity

Upload Frequency

Getting Started

Opt Out

Initialize the SDK

Event Tracking

Commerce Tracking

Error Tracking

Screen Tracking

Identity

Location Tracking

Session Management

Roku

Getting Started

Identity

Media

Xbox

Getting Started

Identity

Xamarin

Getting Started

Identity

Web

Initialization

Configuration

Content Security Policy

Event Tracking

User Attributes

IDSync

Page View Tracking

Commerce Events

Location Tracking

Media

Kits

Application State and Session Management

Data Privacy Controls

Error Tracking

Opt Out

Custom Logger

Persistence

Native Web Views

Self-Hosting

Multiple Instances

Web SDK via Google Tag Manager

Preventing Blocked HTTP Traffic with CNAME

Facebook Instant Articles

Troubleshooting the Web SDK

Browser Compatibility

Linting Data Plans

API Reference

Upgrade to Version 2 of the SDK

Alexa

Guides
Partners

Introduction

Outbound Integrations

Outbound Integrations

Firehose Java SDK

Inbound Integrations

Kit Integrations

Overview

Android Kit Integration

JavaScript Kit Integration

iOS Kit Integration

Compose ID

Data Hosting Locations

Glossary

Migrate from Segment to mParticle

Migrate from Segment to mParticle

Migrate from Segment to Client-side mParticle

Migrate from Segment to Server-side mParticle

Segment-to-mParticle Migration Reference

Rules Developer Guide

Quickstart
HTTP Quick Start

Step 1. Create an input

Step 2. Create an output

Step 3. Verify output

Android

Overview

Step 1. Create an input

Step 2. Verify your input

Step 3. Set up your output

Step 4. Create a connection

Step 5. Verify your connection

Step 6. Track events

Step 7. Track user data

Step 8. Create a data plan

Step 9. Test your local app

iOS Quick Start

Overview

Step 1. Create an input

Step 2. Verify your input

Step 3. Set up your output

Step 4. Create a connection

Step 5. Verify your connection

Step 6. Track events

Step 7. Track user data

Step 8. Create a data plan

Java Quick Start

Step 1. Create an input

Step 2. Create an output

Step 3. Verify output

Node Quick Start

Step 1. Create an input

Step 2. Create an output

Step 3. Verify output

Web

Overview

Step 1. Create an input

Step 2. Verify your input

Step 3. Set up your output

Step 4. Create a connection

Step 5. Verify your connection

Step 6. Track events

Step 7. Track user data

Step 8. Create a data plan

Python Quick Start

Step 1. Create an input

Step 2. Create an output

Step 3. Verify output

Tools

mParticle Command Line Interface

Smartype

Linting Tools

Server SDKs

Node SDK

Go SDK

Python SDK

Ruby SDK

Java SDK

Media SDKs

Android

iOS

Web

API Credential Management

The Developer's Guided Journey to mParticle

Guides
Composable Audiences

Composable Audiences Overview

User Guide

User Guide Overview

Warehouse Setup

Warehouse Setup Overview

Connections

Connections Overview

Google BigQuery

Databricks

Amazon Redshift

Snowflake

Data Models

Data Models Overview

Create a User Data Model

Create an Event Data Model

Create a Generic Data Model

Audience Setup

Frequently Asked Questions

Customer 360

Overview

User Profiles

Overview

User Profiles

Group Identity

Overview

Create and Manage Group Definitions

Calculated Attributes

Calculated Attributes Overview

Using Calculated Attributes

Create with AI Assistance

Calculated Attributes Reference

Predictive Attributes

What are predictive attributes?

Predict Future Behavior

Create Future Prediction

Use Future Predictions in Campaigns

Assess and Troubleshoot Predictions

Next Best Action

Next Best Action Overview

Create a Next Best Action (NBA)

View and Manage NBAs

Activate Next Best Actions in Campaigns

Getting Started

Create an Input

Start capturing data

Connect an Event Output

Create an Audience

Connect an Audience Output

Transform and Enhance Your Data

Platform Guide
Billing

Usage and Billing Report

The New mParticle Experience

The new mParticle Experience

The Overview Map

Platform Settings

Audit Logs (Early Access)

Key Management

Platform Configuration

Observability

Observability Overview

Observability User Guide

Observability Troubleshooting Examples

Observability Span Glossary

Event Forwarding

Notifications

System Alerts

Trends

Introduction

Data Retention

Data Catalog

Connections

Activity

Data Plans

Live Stream

Filters

Rules

Blocked Data Backfill Guide

Tiered Events

mParticle Users and Roles

Analytics Free Trial

Troubleshooting mParticle

Usage metering for value-based pricing (VBP)

IDSync

IDSync Overview

Use Cases for IDSync

Components of IDSync

Store and Organize User Data

Identify Users

Default IDSync Configuration

Profile Conversion Strategy

Profile Link Strategy

Profile Isolation Strategy

Best Match Strategy

Aliasing

Segmentation
Audiences

Audiences Overview

Create an Audience

Connect an Audience

Manage Audiences

Audience Boost (Early Access)

FAQ

Classic Audiences

Standard Audiences (Legacy)

Predictive Audiences

Predictive Audiences Overview

Using Predictive Audiences

New vs. Classic Experience Comparison

Analytics

Introduction

Core Analytics (Beta)

Setup

Sync and Activate Analytics User Segments in mParticle

User Segment Activation

Welcome Page Announcements

Settings

Project Settings

Roles and Teammates

Organization Settings

Global Project Filters

Portfolio Analytics

Analytics Data Manager

Analytics Data Manager Overview

Events

Event Properties

User Properties

Revenue Mapping

Export Data

UTM Guide

Analyses

Analyses Introduction

Segmentation: Basics

Getting Started

Visualization Options

For Clauses

Date Range and Time Settings

Calculator

Numerical Settings

Segmentation: Advanced

Assisted Analysis

Properties Explorer

Frequency in Segmentation

Trends in Segmentation

Did [not] Perform Clauses

Cumulative vs. Non-Cumulative Analysis in Segmentation

Total Count of vs. Users Who Performed

Save Your Segmentation Analysis

Export Results in Segmentation

Explore Users from Segmentation

Funnels: Basics

Getting Started with Funnels

Group By Settings

Conversion Window

Tracking Properties

Date Range and Time Settings

Visualization Options

Interpreting a Funnel Analysis

Funnels: Advanced

Group By

Filters

Conversion over Time

Conversion Order

Trends

Funnel Direction

Multi-path Funnels

Analyze as Cohort from Funnel

Save a Funnel Analysis

Explore Users from a Funnel

Export Results from a Funnel

Cohorts

Getting Started with Cohorts

Analysis Modes

Save a Cohort Analysis

Export Results

Explore Users

Saved Analyses

Manage Analyses in Dashboards

Journeys

Getting Started

Event Menu

Visualization

Ending Event

Save a Journey Analysis

Users

Getting Started

User Activity Timelines

Time Settings

Export Results

Save A User Analysis

Query Builder

Data Dictionary

Query Builder Overview

Modify Filters With And/Or Clauses

Query-time Sampling

Query Notes

Filter Where Clauses

Event vs. User Properties

Group By Clauses

Annotations

Cross-tool Compatibility

Apply All for Filter Where Clauses

Date Range and Time Settings Overview

User Attributes at Event Time

Understanding the Screen View Event

User Aliasing

Dashboards

Dashboards––Getting Started

Manage Dashboards

Dashboard Filters

Organize Dashboards

Scheduled Reports

Favorites

Time and Interval Settings in Dashboards

Query Notes in Dashboards

Analytics Resources

The Demo Environment

Keyboard Shortcuts

User Segments

Tutorials

Analytics for Marketers

Analytics for Product Managers

Compare Conversion Across Acquisition Sources

Analyze Product Feature Usage

Identify Points of User Friction

Time-based Subscription Analysis

Dashboard Tips and Tricks

Understand Product Stickiness

Optimize User Flow with A/B Testing

APIs

User Segments Export API

Dashboard Filter API

Warehouse Sync

Warehouse Sync User Guide

Historical Data and Warehouse Sync

Data Privacy Controls

Data Subject Requests

Default Service Limits

Feeds

Cross-Account Audience Sharing

Import Data with CSV Files

Import Data with CSV Files

CSV File Reference

Glossary

Video Index

Analytics (Deprecated)
Identity Providers

Single Sign-On (SSO)

Setup Examples

Settings

Debug Console

Data Warehouse Delay Alerting

Introduction

Developer Docs

Introduction

Integrations

Introduction

Rudderstack

Google Tag Manager

Segment

Data Warehouses and Data Lakes

Advanced Data Warehouse Settings

AWS Kinesis (Snowplow)

AWS Redshift (Define Your Own Schema)

AWS S3 Integration (Define Your Own Schema)

AWS S3 (Snowplow Schema)

BigQuery (Snowplow Schema)

BigQuery Firebase Schema

BigQuery (Define Your Own Schema)

GCP BigQuery Export

Snowflake (Snowplow Schema)

Snowplow Schema Overview

Snowflake (Define Your Own Schema)

APIs

Dashboard Filter API (Deprecated)

REST API

User Segments Export API (Deprecated)

SDKs

SDKs Introduction

React Native

iOS

Android

Java

JavaScript

Python

Object API

Developer Basics

Aliasing

Integrations
24i

Event

Aarki

Audience

ABTasty

Audience

Actable

Feed

AdChemix

Event

Adikteev

Audience

Event

Adjust

Event

Feed

Adobe Marketing Cloud

Server-to-Server Events

Cookie Sync

Platform SDK Events

Adobe Audience Manager

Audience

Adobe Campaign Manager

Audience

AdMedia

Audience

Adobe Experience Platform

Event

Adobe Target

Audience

AdPredictive

Feed

AgilOne

Event

Algolia

Event

Airship

Audience

Event

Feed

Amazon Advertising

Audience

Amazon Kinesis

Event

Amazon Kinesis Firehose

Audience

Event

Amazon S3

Event

Amazon SNS

Event

Amazon Redshift

Data Warehouse

Amazon SQS

Event

Amobee

Audience

Amplitude

Forwarding Data Subject Requests

Event

Ampush

Event

Audience

Analytics

Audience

Event

Forwarding Data Subject Requests

Anodot

Event

Antavo

Feed

AppLovin

Audience

Event

AppsFlyer

Feed

Event

Forwarding Data Subject Requests

Apptentive

Event

Apptimize

Event

Awin

Event

Batch

Audience

Event

Microsoft Azure Blob Storage

Event

Bidease

Audience

Bing Ads

Event

Bluecore

Event

Apteligent

Event

Bluedot

Feed

Branch

Feed

Event

Forwarding Data Subject Requests

Branch S2S Event

Event

Blueshift

Event

Feed

Forwarding Data Subject Requests

Braze

Audience

Feed

Forwarding Data Subject Requests

Event

Button

Audience

Event

Bugsnag

Event

Cadent

Audience

Census

Feed

Conversant

Event

comScore

Event

CleverTap

Event

Audience

Feed

Cortex

Feed

Event

Forwarding Data Subject Requests

Cordial

Feed

Audience

Criteo

Audience

Event

Crossing Minds

Event

Custom Feed

Custom Feed

CustomerGlu

Event

Feed

Databricks

Data Warehouse

Customer.io

Audience

Event

Feed

Datadog

Event

Didomi

Event

Dynamic Yield

Audience

Event

Eagle Eye

Audience

Epsilon

Event

Everflow

Audience

Facebook

Audience

Event

Emarsys

Audience

Edge226

Audience

Facebook Offline Conversions

Event

Flurry

Event

Google Analytics for Firebase

Event

ForeSee

Event

Foursquare

Audience

Feed

Flybits

Event

FreeWheel Data Suite

Audience

Friendbuy

Event

Google Ad Manager

Audience

Google Analytics

Event

Google Ads

Audience

Event

Google Analytics 4

Event

Google BigQuery

Audience

Data Warehouse

Google Cloud Storage

Audience

Event

Google Enhanced Conversions

Event

Google Marketing Platform

Audience

Event

Cookie Sync

Google Marketing Platform Offline Conversions

Event

Google Pub/Sub

Event

Google Tag Manager

Event

Heap

Event

Herow

Feed

Hightouch

Feed

Hyperlocology

Event

Ibotta

Event

Impact

Event

InMarket

Audience

ID5

Kit

Insider

Event

Audience

Feed

InMobi

Audience

Event

iPost

Audience

Feed

Inspectlet

Event

ironSource

Audience

Intercom

Event

Jampp

Event

Audience

Iterable

Audience

Event

Feed

Kafka

Event

Kayzen

Audience

Event

Kissmetrics

Event

Klaviyo

Audience

Event

Kochava

Feed

Forwarding Data Subject Requests

Event

Kubit

Event

Leanplum

Audience

Event

Feed

LaunchDarkly

Feed

LifeStreet

Audience

LinkedIn

LinkedIn Conversions API Integration

Liftoff

Event

Audience

LiveLike

Event

Localytics

Event

Liveramp

Audience

MadHive

Audience

mAdme Technologies

Event

Mailchimp

Audience

Event

Feed

Marigold

Audience

Mautic

Audience

Event

MediaMath

Audience

Mediasmart

Audience

Microsoft Azure Event Hubs

Event

Microsoft Ads

Microsoft Ads Audience Integration

Mintegral

Audience

Mixpanel

Audience

Event

Forwarding Data Subject Requests

MoEngage

Audience

Event

Feed

Moloco

Audience

Event

Monetate

Event

Movable Ink

Event

Movable Ink - V2

Event

myTarget

Audience

Event

Multiplied

Event

Nami ML

Feed

Nanigans

Event

Narrative

Audience

Event

Feed

NCR Aloha

Event

Neura

Event

OneTrust

Event

Optimizely

Audience

Event

Oracle Responsys

Audience

Event

Paytronix

Feed

Oracle BlueKai

Event

Personify XP

Event

Pilgrim

Event

Feed

Persona.ly

Audience

PieEye

Inbound Data Subject Requests

Pinterest

Audience

Event

Plarin

Event

Postie

Audience

Event

Primer

Event

Pushwoosh

Event

Audience

Punchh

Audience

Event

Feed

Radar

Event

Feed

Qualtrics

Event

Quantcast

Event

Rakuten

Event

Attentive

Event

Feed

Reveal Mobile

Event

Reddit

Audience

Event

Retina AI

Feed

Event

RevenueCat

Feed

Regal

Event

RTB House

Audience

Event

Rokt

Audience

Event

Rokt Thanks and Pay+

Sailthru

Event

Audience

Salesforce Email

Audience

Feed

Event

Salesforce Mobile Push

Event

Salesforce Sales and Service Cloud

Event

Feed

Samba TV

Audience

Event

Scalarr

Event

SendGrid

Audience

Feed

SessionM

Event

Feed

Shopify

Custom Pixel

Feed

ShareThis

Audience

Feed

SimpleReach

Event

Singular

Event

Feed

Singular-DEPRECATED

Event

Skyhook

Event

Slack

Event

Smadex

Audience

SmarterHQ

Event

Snapchat

Audience

Event

Snapchat Conversions

Event

Snowflake

Data Warehouse

Snowplow

Event

Split

Event

Feed

Splunk MINT

Event

Sprig

Audience

Event

StartApp

Audience

Stormly

Audience

Event

Statsig

Event

Feed

Swrve

Event

Feed

Talon.One

Audience

Feed

Event

Loyalty Feed

Tapjoy

Audience

Tapad

Audience

Taplytics

Event

Taptica

Audience

Teak

Audience

The Trade Desk

Audience

Cookie Sync

Event

Ticketure

Feed

TikTok Event

Audience (Deprecated)

Audience

Event

Audience Migration

Treasure Data

Audience

Event

Triton Digital

Audience

TUNE

Event

Twitter

Audience

Event

Valid

Event

Vkontakte

Audience

Voucherify

Audience

Event

Vungle

Audience

Webtrends

Event

Wootric

Event

White Label Loyalty

Event

Xandr

Audience

Cookie Sync

Webhook

Event

Yahoo (formerly Verizon Media)

Cookie Sync

Audience

Yotpo

Feed

YouAppi

Audience

Z2A Digital

Audience

Event

Zendesk

Event

Feed

Remerge

Audience

Event

Feed

Salesforce Sales Cloud is a Customer Relationship Management (CRM) platform designed to manage leads, opportunities, and customer relationships to drive sales growth. Salesforce Service Cloud focuses on customer support, case management, and self-service solutions to improve customer satisfaction.

The Salesforce feed integration allows mParticle to receive data from Sales and Service Cloud. The integration uses data forwarded from Salesforce to mParticle via Salesforce Apex and Handler, which is captured through the mParticle Events API. Once events flow into mParticle, you can use them to build audiences, power downstream tools, and enrich your customer data.

Setup overview

  1. Create a feed input in mParticle: This generates a server-to-server key and secret, which will be used to authenticate API calls from Salesforce.
  2. Configure Salesforce authentication with named credentials: You’ll set up an external credential and named credential in Salesforce, which securely store your mParticle API credentials and endpoint information. This avoids hard-coding secret keys.
  3. Create an apex trigger and handler in Salesforce: The trigger listens for changes in your Salesforce data (for example, a record being created or updated) and passes the information to a handler class. The handler determines event types to send to mParticle.
  4. Implement a callout class: The callout class formats the Salesforce data into the JSON payload expected by the mParticle Events API, uses the named credential for authentication, and makes the outbound HTTP request.
  5. Test and verify in mParticle: By inserting or updating Salesforce records, you can confirm that events are being sent correctly and are visible in mParticle’s Live Stream.

Prerequisites

  • Salesforce admin privileges to create external credentials, principals, permission sets, and named credentials.
  • Salesforce developer access to create a custom object, apex trigger, and apex classes.
  • mParticle account access with permission to create a feed input.

To set up a new connection, please complete the following steps in sequence.

Part 1: Create a feed input in mParticle

  1. Log in to your mParticle account, and go to Data Platform > Setup > Inputs using the left-hand navigation.
  2. Go to the Feeds tab.
  3. Click the Add Feed Input button and select Salesforce Sales and Service Cloud. Alternatively, if you already have a feed, scroll down the page and click the + next to Salesforce Sales and Service Cloud to add a new configuration.
  4. Name your configuration, leave Feed Status as Active.
  5. Choose an Input Protection level:

    • Create and Update Profiles: allows all profile modifications and additions.
    • Only Update Profiles: allows profile modifications only to preexisting profiles in the identity scope, but prevents any new profile additions.
    • Read Only: prevents any profile modifications or new profile additions.
  6. Click Save and copy the generated Server-to-Server Key and Server-to-Server Secret. You will use this in the next subsection to configure authentication (Basic Auth) in Salesforce.

Part 2: Configure Salesforce authentication (named credentials)

Salesforce recommends using both Named Credentials and External Credentials. This keeps secrets out of code and lets you authorize who can make callouts.

2.1 Create an external credential (basic authentication)

  1. Log in to your Salesforce account.
  2. In the Setup page, navigate to Security > Named Credentials > External Credentials, and then click New.
  3. Enter a Label and Name.
  4. Set the Authentication Protocol to Basic Authentication and click Save.
  5. In the Principals section of your External Credential, click New to create a Named Principal and populate:

    • Username: add your mParticle Server-to-Server Key captured previously
    • Password: add your mParticle Server-to-Server Secret captured previously
  6. Click Save.

2.2 Grant access with a permission set (principal access)

  1. In Setup, open Permission Sets and click New.
  2. Give it a name such as mParticle Callouts and click Save.
  3. In the permission set, open External Credential Principal Access, click Edit, and move your principal to Enabled External Credential Principals.
  4. Click Manage Assignments > Add Assignments, and assign the permission set to the users or integration user that will run the callouts.
  5. Select Basic Authentication in the Authentication Protocol dropdown.

2.3 Create a Named Credential that points to mParticle

  1. In Setup > Named Credentials, click New.
  2. Enter a Label and Name (for example, mP_API).
  3. Under URL, enter the mParticle Event API URL for your location (for example, https://s2s.mparticle.com/v2/events). See Data Hosting Locations to find the correct URL for your account’s hosting location.
  4. Select the External Credential you created above.
  5. Check Enabled for Callouts, then click Save.

In Apex, you will call this endpoint using the callout:<NamedCredentialName> syntax.

Part 3: Create the apex trigger and handler

You need to do this with each of your objects. To illustrate the integration, this guide uses a custom object called TestTicket__c with fields including Status__c (picklist: Open, In Progress, Closed) and Email__c. Two example events are sent:

  • Ticket Created when a record is inserted and has an email.
  • Ticket Closed when Status__c changes to Closed and the record has an email.

3.1 What is an Apex Trigger and Handler?

Below is a brief explanation of a few key Salesforce terms to help you better understand and set up the following sections.

Apex Trigger

An Apex Trigger is a small piece of code in Salesforce that runs automatically when certain database events occur, such as when a record is created, updated, or deleted. Triggers enable you to automate actions that happen “behind the scenes,” without requiring a user to click a button or run a process manually.

Handler Class

A Handler is a separate Apex class where you put the actual business logic that the trigger calls. Instead of writing all the logic directly in the trigger, you forward the work to the handler. This makes the code easier to read, maintain, and extend in the future.

Why they matter here

In this integration, the trigger detects changes in Salesforce (for example, when a new record is created or an existing record’s status changes). The trigger then calls the handler, which builds the event payload and sends it out to the mParticle Events API.

In summary:

  • Trigger: watches for changes in your Salesforce data.
  • Handler: decides what to do with those changes (in this case, send events to mParticle).

3.2 Create the Apex Trigger

  1. In Salesforce, go to Setup.
  2. In the Quick Find box, type Apex Triggers and click Apex Triggers.
  3. Click New.
  4. From the Object dropdown, select your object (for example, TestTicket__c).
  5. Enter a Name (for example, TicketTrigger).
  6. Paste in the trigger code provided below.
  7. Click Save.

Trigger code sample

trigger TicketTrigger on TestTicket__c (after insert, after update) {
    if (Trigger.isAfter) {
        if (Trigger.isInsert) {
            TicketTriggerHandler.handleAfterInsert(Trigger.new);
        } else if (Trigger.isUpdate) {
            TicketTriggerHandler.handleAfterUpdate(Trigger.oldMap, Trigger.newMap);
        }
    }
}

3.3 Create the Apex Handler Class

  1. In Salesforce, go to Setup.
  2. In the Quick Find box, type Apex Classes and click Apex Classes.
  3. Click New.
  4. Enter a Class Name (for example, TicketTriggerHandler).
  5. Paste in the handler class code provided below.
  6. Click Save.

Once saved, Salesforce immediately compiles the trigger and handler. Any time a record event (insert or update) matches your trigger conditions, Salesforce will run the logic in the handler and send the event to mParticle.

Handler code sample

public class TicketTriggerHandler {
    public static void handleAfterInsert(List<TestTicket__c> newTickets) {
        for (TestTicket__c t : newTickets) {
            if (String.isNotBlank(t.Email__c)) {
                MParticleIntegration.sendTicketCreatedEvent(t.Email__c, t.Id, t.Name);
            }
        }
    }

    public static void handleAfterUpdate(Map<Id, TestTicket__c> oldMap, Map<Id, TestTicket__c> newMap) {
        for (Id id : newMap.keySet()) {
            TestTicket__c oldT = oldMap.get(id), newT = newMap.get(id);
            Boolean wasNotClosed = oldT.Status__c != 'Closed';
            Boolean isNowClosed  = newT.Status__c == 'Closed';
            if (wasNotClosed && isNowClosed && String.isNotBlank(newT.Email__c)) {
                MParticleIntegration.sendTicketClosedEvent(newT.Email__c, newT.Id, newT.Name);
            }
        }
    }
}

Part 4: Implement the mParticle callout class

In Salesforce, a callout is any outbound HTTP request that Salesforce makes to an external system. A callout class is simply an apex class designed to handle these outbound requests. It usually sets up the endpoint, authentication, headers, and body of the request, then sends it and processes the response.

In this integration, the callout class is responsible for sending the event data from Salesforce to mParticle:

  • It formats your Salesforce data into the JSON shape expected by the mParticle Events API.
  • It uses your Named Credential to securely add authentication details and point to the correct regional endpoint.
  • It sends the request and logs whether it succeeded or failed.

By separating this logic into a dedicated callout class, you keep your trigger and handler simple (they just detect changes and hand off the work). The callout class handles all the details of making the actual API request.

4.1 Create the callout class

  1. In Salesforce, go to Setup.
  2. In the Quick Find box, type Apex Classes and click Apex Classes.
  3. Click New.
  4. Enter a Class Name (for example, MParticleIntegration).
  5. Paste in the full callout class code sample below.
  6. Click Save.

After saving, Salesforce will compile the class. Since the methods are marked with @future(callout=true), they can be invoked by your handler asynchronously and will be allowed to make HTTP callouts to the mParticle Events API. The actual endpoint and authentication are managed by the Named Credential you configured earlier.

Callout class code sample

public class MParticleIntegration {
    @future(callout=true)
    public static void sendTicketCreatedEvent(String email, Id recordId, String ticketName) {
        String orgBase = System.URL.getOrgDomainUrl().toExternalForm();
        String recordUrl = orgBase + '/' + recordId;

        Map<String, Object> event = new Map<String, Object>{
            'event_type' => 'custom_event',
            'data' => new Map<String, Object>{
                'event_name' => 'Ticket Created',
                'custom_event_type' => 'other',
                'custom_attributes' => new Map<String, Object>{ 'Ticket Name' => ticketName }
            }
        };

        Map<String, Object> payload = new Map<String, Object>{
            'events' => new List<Object>{ event },
            'user_identities' => new Map<String, Object>{ 'email' => email },
            'user_attributes' => new Map<String, Object>{ 'Last Open Ticket' => recordUrl },
            'environment' => 'development'
        };

        sendMParticleEvent(payload, 'Ticket Created');
    }

    @future(callout=true)
    public static void sendTicketClosedEvent(String email, Id recordId, String ticketName) {
        Map<String, Object> event = new Map<String, Object>{
            'event_type' => 'custom_event',
            'data' => new Map<String, Object>{
                'event_name' => 'Ticket Closed',
                'custom_event_type' => 'other',
                'custom_attributes' => new Map<String, Object>{ 'Ticket Name' => ticketName }
            }
        };

        Map<String, Object> payload = new Map<String, Object>{
            'events' => new List<Object>{ event },
            'user_identities' => new Map<String, Object>{ 'email' => email },
            'environment' => 'development'
        };

        sendMParticleEvent(payload, 'Ticket Closed');
    }

    private static void sendMParticleEvent(Map<String, Object> payload, String label) {
        HttpRequest req = new HttpRequest();
        // Named Credential created in Part 2.3
        req.setEndpoint('callout:mP_API/events');
        req.setMethod('POST');
        req.setHeader('Content-Type', 'application/json');
        req.setBody(JSON.serialize(payload));

        Http http = new Http();
        HttpResponse res = http.send(req);

        if (res.getStatusCode() >= 200 && res.getStatusCode() < 300) {
            System.debug(label + ' sent to mParticle. ' + res.getStatus());
        } else {
            System.debug('mParticle error: ' + res.getStatus() + ' - ' + res.getBody());
        }
    }
}

Part 5: Test the integration

Before going live, test the integration to confirm that Salesforce triggers and callouts are functioning correctly and that events arrive in mParticle as expected. You can use the Salesforce Developer Console to insert and update sample records, review logs, and then verify the resulting events in mParticle’s Live Stream.

5.1 Open the Developer Console

  1. In Salesforce, click your avatar in the top right corner.
  2. Select Developer Console.

5.2 Insert a test record

  1. In the Developer Console, go to Debug > Open Execute Anonymous Window.
  2. Paste the following code and click Execute:
TestTicket__c t = new TestTicket__c(
    Email__c='test@example.com',
    Details__c='Something went wrong'
);
insert t;
  1. This insert fires the trigger and queues the Ticket Created callout.

5.3 Check the callout job

  1. In the Developer Console, open the Logs tab.
  2. Look for a log entry from the MParticleIntegration class.
  3. Open the log and confirm that the HTTP request was sent and returned a 200/202 response.

5.4 Verify the event in mParticle Live Stream

  1. Log in to your mParticle account.
  2. Open Live Stream.
  3. Set Environment to Development (the example payloads use environment: "development").
  4. Filter by Source to your Salesforce Sales and Service Cloud feed if needed.
  5. Search for the email address test@example.com.
  6. Confirm that you see a Ticket Created event.

5.5 Update the record to trigger “Ticket Closed”

  1. In the Developer Console, open the Execute Anonymous window again.
  2. Paste the following code and click Execute:
TestTicket__c t = [
    SELECT Id FROM TestTicket__c 
    WHERE Email__c='test@example.com' 
    ORDER BY CreatedDate DESC LIMIT 1
];
t.Status__c = 'Closed';
update t;
  1. This update fires the trigger and queues the Ticket Closed callout.
  2. Repeat steps 5.3 and 5.4 to confirm that the Apex job has completed and that a Ticket Closed event appears in mParticle Live Stream.

5.6 Capture debug logs (optional)

If you want detailed System.debug output:

  1. In the Developer Console, go to Debug > Change Log Levels.
  2. Set Apex Code to DEBUG.
  3. Re-run the insert/update steps, then open the resulting logs to inspect debug output from your trigger, handler, and callout class.

Part 6: Expected results

  • Logs show successful execution of the MParticleIntegration methods.
  • In Live Stream, you see the corresponding Ticket Created and Ticket Closed events for the email identity you used.
    Last Updated: October 17, 2025