Documentation

Developers

API References
Data Subject Request API

Data Subject Request API Version 1 and 2

Data Subject Request API Version 3

Platform API

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

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

Roku

Getting Started

Identity

Media

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

Xbox

Getting Started

Identity

Unity

Upload Frequency

Getting Started

Opt Out

Initialize the SDK

Event Tracking

Commerce Tracking

Error Tracking

Screen Tracking

Identity

Location Tracking

Session Management

Web

Initialization

Content Security Policy

Configuration

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

Xamarin

Getting Started

Identity

Web

Alexa

Server SDKs

Node SDK

Go SDK

Python SDK

Ruby SDK

Java SDK

Tools

mParticle Command Line Interface

Linting Tools

Smartype

Media SDKs

Android

Web

iOS

Quickstart
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

HTTP Quick Start

Step 1. Create an input

Step 2. Create an output

Step 3. Verify output

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

Python 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

Guides
Partners

Introduction

Outbound Integrations

Outbound Integrations

Firehose Java SDK

Inbound Integrations

Kit Integrations

Overview

Android Kit Integration

JavaScript Kit Integration

iOS Kit Integration

Data Hosting Locations

Compose ID

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

API Credential Management

The Developer's Guided Journey to mParticle

Guides

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
The New mParticle Experience

The new mParticle Experience

The Overview Map

Observability

Observability Overview

Observability User Guide

Observability Span Glossary

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)

Analytics

Introduction

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

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

Understanding the Screen View Event

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

Dashboards

Dashboards––Getting Started

Manage Dashboards

Organize Dashboards

Dashboard Filters

Scheduled Reports

Favorites

Time and Interval Settings in Dashboards

Query Notes in Dashboards

User Aliasing

Analytics Resources

The Demo Environment

Keyboard Shortcuts

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

User Segments

APIs

User Segments Export API

Dashboard Filter API

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

Data Master
Group Identity

Overview

Create and Manage Group Definitions

Introduction

Catalog

Live Stream

Data Plans

Data Plans

Blocked Data Backfill Guide

Personalization
Predictive Attributes

Predictive Attributes Overview

Create Predictive Attributes

Assess and Troubleshoot Predictions

Use Predictive Attributes in Campaigns

Predictive Audiences

Predictive Audiences Overview

Using Predictive Audiences

Introduction

Profiles

Calculated Attributes

Calculated Attributes Overview

Using Calculated Attributes

Create with AI Assistance

Calculated Attributes Reference

Audiences

Audiences Overview

Real-time Audiences

Standard Audiences

Journeys

Journeys Overview

Manage Journeys

Download an audience from a journey

Audience A/B testing from a journey

Journeys 2.0

Warehouse Sync

Data Privacy Controls

Data Subject Requests

Default Service Limits

Feeds

Cross-Account Audience Sharing

Approved Sub-Processors

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

User Attributes

The SDK surfaces a series of APIs to associate “attributes” with a user. Attributes can be any set of free-form keys and values. It’s important to understand the following before reading on:

  • The SDK maintains a “current” user in tandem with usage of the IDSync APIs, which you can read more about here.
  • On first SDK initialization, there is no current user and the APIs below will return null
  • Once the SDK has successfully called the IDSync identify API for the first time, you will be able to access the current user via the MParticleUser object
  • Any events recorded prior to the first IDSync API call will be associated with the first user. The SDK will not upload data until the first IDSync API call has returned.

mParticle ID

All users are associated with a signed 64-bit integer called the mParticle ID (MPID). Note that this value may be negative. Many mParticle integrations send data associated with an MPID. MPIDs are shared across devices depending on your IDSync strategy and usage of the IDSync API.

Current user

The SDK maintains a “current” user and will associate all events with the current user at the time that they occur. There are several ways to retrieve a reference to the current user object:

Direct Query

Query the SDK directly for the current user. Note that this is a non-blocking call so will be fast, but may return null on the first app launch if no IDSync API call has ever succeeded.

// Note: may return null if the SDK has yet to acquire a user via IDSync!
MParticleUser currentUser = MParticle.getInstance().Identity().getCurrentUser();

// Retrieve the mParticle ID of this user
long mpid = currentUser.getId();
// Note: may return null if the SDK has yet to acquire a user via IDSync!
val currentUser = MParticle.getInstance().Identity().currentUser

// Retrieve the mParticle ID of this user
val mpid = currentUser?.id

Listener

You can set a global listener to be alerted when the current user (or MPID) changes. This will only ever be called when the current MPID changes, such as on the initial application install or after an IDSync login or logout.

MParticle.getInstance().Identity().addIdentityStateListener(new IdentityStateListener() {
    @Override
    public void onUserIdentified(MParticleUser currentUser) {
    	//currentUser will never be null
    	long mpid = currentUser.getId();
    }
});
MParticle.getInstance().Identity().addIdentityStateListener { currentUser ->
    //currentUser will never be null
    val mpid = currentUser.id
}

IDSync API Result

Whenever an IDSync API is invoked, the IdentityApiResult object returned for a successful request will contain a reference to the new user object and mParticle ID. See the IDSync page for more information. Note that depending on your IDSync strategy, the MPID (and therefore the current user) may not change for every IDSync API call, such as for new user registration (login) scenarios.

Set User Attributes

User attributes are free-form key-value pairs. The underlying mParticle events API only accepts three types of values: strings, lists, and the JSON null sentinel in the case of tags. The Android SDK provides several helper methods that let you pass in non-strings - but these values will always be converted to strings. If you’re concerned about how this occurs for your values, you should convert the value to a string prior to passing it to the Android APIs.

// Note: may return null if the SDK has yet to acquire a user via IDSync!
MParticleUser currentUser = MParticle.getInstance().Identity().getCurrentUser();

// Set user attributes associated with the user 
currentUser.setUserAttribute("top_region","Europe");

// You can change the value of an existing attribute at any time
currentUser.setUserAttribute("top_region","North America");

// Increment a user attribute by an integer value, this will:
// - look for an existing "trips_booked" value, 
// - cast it to an integer and increment it
// - cast the result back to an string for storage and upload
currentUser.incrementUserAttribute("trips_booked", 1);

// Associate a list of values with an attribute key
List<String> attributeList = new ArrayList<>();
attributeList.add("Rome");
attributeList.add("San Juan");
attributeList.add("Denver");
currentUser.setUserAttributeList("destinations", attributeList);

// Remove attribute - 
// all attributes for a given user share the same key space,
// you cannot have lists, tags and regular attributes with the same key
currentUser.removeUserAttribute("top_region");
// Note: may return null if the SDK has yet to acquire a user via IDSync!
val currentUser = MParticle.getInstance().Identity().currentUser

// Set user attributes associated with the user 
currentUser?.setUserAttribute("top_region", "Europe")

// You can change the value of an existing attribute at any time
currentUser?.setUserAttribute("top_region", "North America")

// Increment a user attribute by an integer value, this will:
// - look for an existing "trips_booked" value, 
// - cast it to an integer and increment it
// - cast the result back to an string for storage and upload
currentUser?.incrementUserAttribute("trips_booked", 1)

// Associate a list of values with an attribute key
val attributeList = ArrayList<String>()
attributeList.add("Rome")
attributeList.add("San Juan")
attributeList.add("Denver")
currentUser?.setUserAttributeList("destinations", attributeList)

// Remove attribute - 
// all attributes for a given user share the same key space,
// you cannot have lists, tags and regular attributes with the same key
currentUser?.removeUserAttribute("platinum_member")

Set User Tags

A tag is a label or category to which a user belongs. While the SDK sets a tag as a string, mParticle’s master data structure defines attributes as a map, so tags are stored with a null value. For example, when you set the "platinum_member" tag on a user, the user profile will get the attribute "platinum_member": NULL.

// Set tag
// Note: may return null if the SDK has yet to acquire a user via IDSync!
val currentUser = MParticle.getInstance().Identity().getCurrentUser();
currentUser.setUserTag("platinum_member");

// Remove tag
currentUser.removeUserAttribute("platinum_member");
// Set tag
// Note: may return null if the SDK has yet to acquire a user via IDSync!
val currentUser = MParticle.getInstance().Identity().currentUser

// Set tag
currentUser.setUserTag("platinum_member")

// Remove tag
currentUser.removeUserAttribute("platinum_member")

User Attribute Change Events

The SDK will upload an event whenever a user attribute changes to denote new attributes, changing attributes, and removed attributes. This is to allow for calculation of the current user attribute state for each event within an mParticle upload.

Reserved Attributes

Below is a list of mParticle “reserved” user attribute keys. Several integrations use these keys for deterministic data mapping:

  • $Age
  • $FirstName
  • $LastName
  • $Gender
  • $Mobile
  • $Address
  • $City
  • $State
  • $Zip
  • $Country

The Android SDK surfaces an interface such that you can use these more easily - reference the complete API reference for more information.

Attribute Key Limitations

Always refer to your organization’s data plan when instrumenting user or event attributes. Each unique attribute key becomes a data point in the mParticle user interface that can be filtered for each output, used to drive the calculation of an audience or become part of a custom mapping. This means that your choice of attribute keys can have a system-wide impact. For example, if you have a single attribute key per device that represents a unique user ID or a unique URL, and you have thousands of users, mParticle will see thousands of unique keys, even though you only create one per device.

Creating too many unique attribute keys can have several adverse effects:

  • The mParticle dashboard becomes overcrowded and it becomes harder for business users to manage individual data points
  • Each individual data point can be switched on or off as a data filter. If you filter data to kits, this filter information is downloaded by the SDK during your app’s initialization. The more unique data points you have, the larger the size of the download. If not controlled this can ultimately impact the performance of your app.
  • A high number of unique attribute keys makes it difficult for you to use mParticle features like rules and audience builder to control your data flow.

You should avoid the following as attribute keys:

  • URLs
  • Dates
  • Dynamic strings
  • User IDs
  • Random IDs

Example

A gaming app has ten levels and you want to track which level each user has achieved. Rather than creating ten tags such “reachedLevel1”, “reachedLevel2”, it is better to create a single attribute “reachedLevel” and use the value as the level.

Capturing this data as a single attribute improves the performance of both your app and the mParticle dashboard by reducing the number of unique data points you need to manage. It’s also a much more useful data point. For example, you can easily create a single audience builder condition to target users within a range of levels reached.

Cross-Platform Attribute tracking

An mParticle workspace can combine data from multiple platforms, for example it can show data from the same app running in iOS and Android. For this reason, you may wish to choose attribute names that you can keep consistent across all platforms for easier management. For example, if you call an attribute levelReached in iOS, LevelReached on Android, and level_reached on web, mParticle will treat these as three separate attributes.

Integration Attributes

Several partner integrations expect custom keys and values associated with each user or device, known as integration attributes. These are similar to “custom flags” except rather than being specific to an event, they’re specific to a user or device. The most common example of this are partner-specific user or device IDs.

The Android SDK will persist any integration attributes at the device-level (rather than user-level), and will include them with every event upload. You can set an integration attribute by specifying an integration ID as well as a key and value:

//update the partner ID and attribute key as necessary for your integration
int adobePartnerId = 11;
String adobeIntegrationAttributeKey = "vid";

Map<String, String> integrationAttributes = new HashMap<String, String>();
integrationAttributes.put(adobeIntegrationAttributeKey, "<Adobe Visitor ID>");
MParticle.getInstance().setIntegrationAttributes(11, integrationAttributes);
val adobePartnerId = 11
val adobeIntegrationAttributeKey = "vid"

val integrationAttributes: MutableMap<String, String> = HashMap()
integrationAttributes[adobeIntegrationAttributeKey] = "<Adobe Visitor ID>"
MParticle.getInstance().setIntegrationAttributes(11, integrationAttributes)

Was this page helpful?

    Last Updated: December 5, 2024