Data Subject Request API Version 1 and 2
Data Subject Request API Version 3
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
Custom Access Roles API
Bulk Profile Deletion API Reference
Data Planning API
Group Identity API Reference
Calculated Attributes Seeding API
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
Linting Data Plans
Troubleshooting the Android SDK
API Reference
Upgrade to Version 5
Cordova Plugin
Identity
Direct URL Routing FAQ
Web
Android
iOS
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
Getting Started
Identity
Upload Frequency
Getting Started
Opt Out
Initialize the SDK
Event Tracking
Commerce Tracking
Error Tracking
Screen Tracking
Identity
Location Tracking
Session Management
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
Getting Started
Identity
Web
Alexa
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
Step 1. Create an input
Step 2. Create an output
Step 3. Verify output
Node SDK
Go SDK
Python SDK
Ruby SDK
Java SDK
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
API Credential Management
The Developer's Guided Journey to mParticle
Create an Input
Start capturing data
Connect an Event Output
Create an Audience
Connect an Audience Output
Transform and Enhance Your Data
The new mParticle Experience
The Overview Map
Introduction
Data Retention
Connections
Activity
Live Stream
Data Filter
Rules
Tiered Events
mParticle Users and Roles
Analytics Free Trial
Troubleshooting mParticle
Usage metering for value-based pricing (VBP)
Introduction
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
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
Understanding the Screen View Event
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
Dashboards––Getting Started
Manage Dashboards
Dashboard Filters
Organize Dashboards
Scheduled Reports
Favorites
Time and Interval Settings in Dashboards
Query Notes in Dashboards
User Aliasing
The Demo Environment
Keyboard Shortcuts
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
User Segments
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
Overview
Create and Manage Group Definitions
Introduction
Catalog
Live Stream
Data Plans
Blocked Data Backfill Guide
Predictive Attributes Overview
Create Predictive Attributes
Assess and Troubleshoot Predictions
Use Predictive Attributes in Campaigns
Predictive Audiences Overview
Using Predictive Audiences
Introduction
Profiles
Warehouse Sync
Data Privacy Controls
Data Subject Requests
Default Service Limits
Feeds
Cross-Account Audience Sharing
Approved Sub-Processors
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
Smartype is a powerful code generation tool, built for mParticle’s Data Master, that allows you to turn your Data Plans into useable, type-safe code.
It aims to completely eliminate an entire class of data quality bugs 🐛 by generating statically-typed data models based on the popular JSON schema standard.
The following JSON schema describes a coffee order with a few required parameters:
Smartype does the following with this:
data
classesSmartype supports the following SDKs and language environments today:
Any JVM environment:
Smartype is designed to work with mParticle Data Plans. If you haven’t yet created a Data Plan, you’ll need to do so and download your data plan to work with Smartype.
Once you’ve created your Data Plan(s), we suggest you download them and commit them to source control. That way you can generate Smartype models in your CI system and development environment.
There are a few ways to acquire a data plan:
Smartype is shipped as a CLI tool, and so your typical workflow could be:
Rather than manually creating a JSON file, mParticle provides these files ready for use by Smartype. There are multiple ways to retrieve them, but for automation purposes using the mParticle CLI tool is the best option.
We provide a ready-to-use Github Actions workflow file here, which can be adapted to other CI systems: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/data-plan-fetch.yml
Individual developers can also manually download the Data Plan JSON by using the mParticle CLI directly from the command line.
npm install -g @mparticle/cli
.Once the mParticle CLI has been installed, the Data Plan JSON can be downloaded using a single command.
First you will need the following pieces of information:
You can create and manage your mParticle access tokens for Data Planning with the API Credentials interface.
# Here we'll use environment variables, but you can simply pass the values directly to the mp command if you'd prefer
export $DATA_PLAN_ID=...
export $DATA_PLAN_VERSION=...
export $WORKSPACE_ID=...
export $CLIENT_ID=...
export $CLIENT_SECRET=...
# $OUT_FILE can be any file name you like
export $OUT_FILE=${DATA_PLAN_ID}_${DATA_PLAN_VERSION}.json
# Pull down the JSON file
mp planning:data-plan-versions:fetch --dataPlanId=$DATA_PLAN_ID --versionNumber=$DATA_PLAN_VERSION --workspaceId=$WORKSPACE_ID --clientId=$CLIENT_ID --clientSecret=$CLIENT_SECRET --outFile=$OUT_FILE
Smartype is deployed as an executable Java-based CLI. It has several commands which are documented in the sections below.
You can use mvnx to automate the download and execution of Smartype:
# First install the mvnx package, which downloads and runs jar executables from Maven Central
npm install -g mvnx
# Then run either init or generate directly
mvnx com.mparticle:smartype-generator init
You can also download the latest release from the Github releases page, and then execute it:
java -jar smartype-generator.jar
You will need to ensure that a Java SDK is available on your PATH, you can do this by:
JAVA_HOME
environment variable via export JAVA_HOME=~/path/to/jdk/home
replacing the path with the home
directory of the downloaded JDK (or an existing JDK already present in your environment)The CLI provides two key commands:
init
: Initialize a configuration file that’s used by Smartype to generate code.generate
: Generates strongly-type libraries based on your data modelinit
Smartype init
will ask you a series of questions and then create a Smartype configuration file.
When choosing a folder for Smartype files to be written to, as part of the generate
step, be sure to create a new folder specific to Smartype so the new files don’t pollute existing folders.
# With mvnx:
mvnx com.mparticle:smartype-generator init
# Or directly execute the pre-downloaded jar
java -jar smartype-generator-[version].jar init
generate
Smartype generate
will read your configuration file and output binaries that are ready for consumption in an application.
# With mvnx:
mvnx com.mparticle:smartype-generator generate
# Or directly execute the pre-downloaded jar
java -jar smartype-generator-[version].jar generate
To use the objects created by Smartype, you’ll want to add the generated code to your projects. You will also want to initialize Smartype when the app starts up, and register any receivers that you would like to get notified for each message that gets logged.
The following code snippets use the mParticle receiver as an example, but receivers can be created to wrap any interface to which you want to send data, including for your own inhouse processing.
Smartype requires Xcode and Carthage to be installed.
generate
The following command will generate an iOS “fat” framework containing all architectures. You can customize the output directory of the framework via Smartype init
# With mvnx:
mvnx com:mparticle:smartype-generator generate
# Or directly execute the pre-downloaded jar
java -jar smartype-generator-[version].jar generate
Smartype generate
will create a “fat” dynamic framework that you can include directly with your projects. To use Smartype on iOS, start by adding Smartype.framework
to your Xcode project
SmartypeApi
object will surface a series of methods which each represent the top-level items in your schemaSmartypeApi
instance for all receivers import Smartype
...
let api = SmartypeApi(receivers: [MParticleReceiver(), self])
let options = MParticleOptions.init(
key: "REPLACE WITH KEY",
secret: "REPLACE WITH SECRET")
//SmartypeApi surfaces the data plan ID and version of the underlying models
options.dataPlanId = api.dataPlanId
options.dataPlanVersion = api.dataPlanVersion as NSNumber
let chooseCustomAttributes = ChooseItemDataCustomAttributes
.init(quantity: 5,
milk: true,
item: .cortado
)
let itemData = ChooseItemData.init(customAttributes: chooseCustomAttributes)
//Smartype surfaces all mParticle "Data Points" as factory methods
let chooseItem = api.chooseItem(data: itemData)
api.send(message: chooseItem)
For Android apps, Smartype generate
will create an aar
file that you can include directly with your projects.
To generate an Android library, set your ANDROID_SDK_ROOT
environment variable via export ANDROID_SDK_ROOT=/Users/<REPLACE>/Library/Android/sdk
replacing the path with your user directory or to wherever an Android SDK is available on your machine
generate
The following command will generate an aar
. You can customize the output directory of the aar via Smartype init
# With mvnx:
mvnx com:mparticle:smartype-generator generate
# Or directly execute the pre-downloaded jar
java -jar smartype-generator-[version].jar generate
smartype.aar
to your projectcom.mparticle:smartype-mparticle
receiver Maven Central dependencydependencies {
//include the generated aar in your project
implementation fileTree(dir: 'libs', include: ['**/*.aar'])
//add the mParticle receiver, which will automatically pull in mParticle as a dependency
implementation "com.mparticle:smartype-mparticle:1.0.2"
}
SmartypeApi
object will surface a series of methods which each represent the top-level items in your schemaSmartypeApi
instance for all receivers val api = SmartypeApi(listOf(MParticleReceiver(), this))
val options = MParticleOptions.builder(this)
.credentials("REPLACE WITH KEY", "REPLACE WITH SECRET")
//SmartypeApi surfaces the data plan ID and version of the underlying models
.dataplan(api.dataPlanId, api.dataPlanVersion)
.build()
val message = api.chooseItem(
ChooseItemData(
ChooseItemDataCustomAttributes(
quantity = 5.0,
milk = true,
item = ChooseItemDataCustomAttributesItem.CORTADO
)
)
)
//the message object will now be sent to mParticle's SDK
api.send(message)
Smartype generate
will create a set of .js
and .d.ts
files that you can include directly with your projects. Our example uses webpack to concatenate and minify the source files.
To use Smartype on Web, start by adding the generated smartype-dist
directory to your project and any 3rd-party receivers that you plan on using, then include the relevant files in your typescript or javascript sources:
import * as kotlin from "../smartype-dist/kotlin.js"
import * as smartype from "../smartype-dist/smartype-smartype.js"
import * as smartypeMparticle from "../smartype-dist/smartype-smartype-mparticle.js"
// create namespace references for easier access
var api = smartype.com.mparticle.smartype
var receivers = smartypeMparticle.com.mparticle.smartype.api.receivers
SmartypeApi
object will surface a series of methods which each represent the top-level items in your schemaSmartypeApi
instance for all receivers var smartypeApi = new api.SmartypeApi()
smartypeApi.addReceiver(new receivers.mparticle.MParticleReceiver())
smartypeApi.addReceiver(this)
var message = smartypeApi.chooseItem(
new api.ChooseItemData(
new api.ChooseItemDataCustomAttributes(
1, true, new api.ChooseItemDataCustomAttributesItem().REGULARCOFFEE()
)
)
)
//the message object will now be sent to all receivers
api.send(message)
In order to enable React Native:
mParticleReceiver
:import MParticle from 'react-native-mparticle'
...
var api = new smartype.SmartypeApi()
var receiver = smartype.mParticleReceiver()
receiver.react = MParticle
api.addReceiver(receiver)
You will also want to exclude the generated .smartype
directory from your React Project by configuring your metro.config.js
file:
const exclusionList = require('metro-config/src/defaults/exclusionList');
...
module.exports = {
resolver: {
blockList: exclusionList([/\.smartype\/.*/])
},
};
Smartype is in a Beta release and we need your help to make it better. For any questions or feedback, please send a note to developers@mparticle.com
Was this page helpful?