Data Subject Request API Version 1 and 2
Data Subject Request API Version 3
Key Management
Platform API Overview
Accounts
Apps
Audiences
Calculated Attributes
Data Points
Feeds
Field Transformations
Services
Users
Workspaces
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
AMP SDK
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 Plugin
Identity
Direct URL Routing FAQ
Web
Android
iOS
Getting Started
Identity
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
Upload Frequency
Getting Started
Opt Out
Initialize the SDK
Event Tracking
Commerce Tracking
Error Tracking
Screen Tracking
Identity
Location Tracking
Session Management
Getting Started
Identity
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
Introduction
Outbound Integrations
Firehose Java SDK
Inbound Integrations
Compose ID
Data Hosting Locations
Glossary
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
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
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
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 1. Create an input
Step 2. Create an output
Step 3. Verify output
Node SDK
Go SDK
Python SDK
Ruby SDK
Java SDK
API Credential Management
The Developer's Guided Journey to mParticle
Composable Audiences Overview
User Guide Overview
Warehouse Setup Overview
Audience Setup
Frequently Asked Questions
Overview
Overview
User Profiles
Overview
Create and Manage Group Definitions
Calculated Attributes Overview
Using Calculated Attributes
Create with AI Assistance
Calculated Attributes Reference
What are predictive attributes?
Create an Input
Start capturing data
Connect an Event Output
Create an Audience
Connect an Audience Output
Transform and Enhance Your Data
Usage and Billing Report
The new mParticle Experience
The Overview Map
Audit Logs (Early Access)
Key Management
Platform Configuration
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 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
Audiences Overview
Create an Audience
Connect an Audience
Manage Audiences
Audience Boost (Early Access)
FAQ
Standard Audiences (Legacy)
Predictive Audiences Overview
Using Predictive Audiences
New vs. Classic Experience Comparison
Introduction
Core Analytics (Beta)
Sync and Activate Analytics User Segments in mParticle
User Segment Activation
Welcome Page Announcements
Project Settings
Roles and Teammates
Organization Settings
Global Project Filters
Portfolio Analytics
Analytics Data Manager Overview
Events
Event Properties
User Properties
Revenue Mapping
Export Data
UTM Guide
Analyses Introduction
Getting Started
Visualization Options
For Clauses
Date Range and Time Settings
Calculator
Numerical Settings
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
Getting Started with Funnels
Group By Settings
Conversion Window
Tracking Properties
Date Range and Time Settings
Visualization Options
Interpreting a Funnel Analysis
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
Saved Analyses
Manage Analyses in Dashboards
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––Getting Started
Manage Dashboards
Dashboard Filters
Organize Dashboards
Scheduled Reports
Favorites
Time and Interval Settings in Dashboards
Query Notes in Dashboards
The Demo Environment
Keyboard Shortcuts
User Segments
Data Privacy Controls
Data Subject Requests
Default Service Limits
Feeds
Cross-Account Audience Sharing
Import Data with CSV Files
CSV File Reference
Glossary
Video Index
Single Sign-On (SSO)
Setup Examples
Introduction
Introduction
Introduction
Rudderstack
Google Tag Manager
Segment
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)
Aliasing
Event
Audience
Audience
Feed
Event
Server-to-Server Events
Cookie Sync
Platform SDK Events
Audience
Audience
Audience
Event
Audience
Feed
Event
Event
Audience
Event
Event
Event
Data Warehouse
Event
Audience
Event
Feed
Event
Event
Event
Event
Audience
Event
Event
Event
Feed
Event
Event
Audience
Feed
Event
Event
Event
Custom Feed
Data Warehouse
Event
Event
Audience
Event
Audience
Audience
Audience
Event
Event
Event
Event
Event
Audience
Event
Audience
Event
Event
Audience
Data Warehouse
Event
Audience
Event
Cookie Sync
Event
Event
Event
Event
Feed
Feed
Event
Event
Event
Audience
Kit
Event
Audience
Event
Event
Event
Event
Feed
Audience
Event
Event
Audience
Audience
Event
Audience
Audience
Audience
Event
Microsoft Ads Audience Integration
Audience
Event
Event
Event
Event
Feed
Event
Event
Event
Event
Feed
Event
Event
Audience
Event
Event
Event
Event
Event
Event
Feed
Event
Event
Event
Custom Pixel
Feed
Event
Event
Event
Event
Audience
Event
Event
Data Warehouse
Event
Event
Audience
Audience
Feed
Event
Loyalty Feed
Audience
Audience
Event
Audience
Audience
Audience
Cookie Sync
Event
Feed
Audience
Event
Event
Audience
Audience
Event
Event
Event
Audience
Cookie Sync
Event
Cookie Sync
Audience
Feed
Audience
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.
To set up a new connection, please complete the following steps in sequence.
Choose an Input Protection level:
Salesforce recommends using both Named Credentials and External Credentials. This keeps secrets out of code and lets you authorize who can make callouts.
In the Principals section of your External Credential, click New to create a Named Principal and populate:
mP_API
).https://s2s.mparticle.com/v2/events
). See Data Hosting Locations to find the correct URL for your account’s hosting location.In Apex, you will call this endpoint using the callout:<NamedCredentialName>
syntax.
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:
Status__c
changes to Closed and the record has an email.Below is a brief explanation of a few key Salesforce terms to help you better understand and set up the following sections.
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.
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.
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:
TestTicket__c
).TicketTrigger
).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);
}
}
}
TicketTriggerHandler
).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);
}
}
}
}
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:
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.
MParticleIntegration
).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());
}
}
}
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.
TestTicket__c t = new TestTicket__c(
Email__c='test@example.com',
Details__c='Something went wrong'
);
insert t;
environment: "development"
).test@example.com
.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;
If you want detailed System.debug
output:
MParticleIntegration
methods.