Segment

Segment is a data analytics hub that allows you to track your users and route that data to a wide variety of user analytics providers, such as Braze.

We offer both a side-by-side SDK integration for your Android, iOS, and web applications and a server-to-server integration for your backend services so that you can start building richer user profiles.

If you’re looking for information on the Currents integration with Segment, click here. If you’re looking for more information about Segment Personas, which allows you to build segments in Segment and pass over to Braze as a custom attribute against a user profile.

Setup Overview

To get going with your Segment/Braze integration,

  1. Take note of and prepare for your integration by adhering to the requirements and prerequisites.
  2. Set up Braze as a Destination in accordance with your chosen integration type.
  3. If you’re a new-to-Braze customer, you can relay historical data to Braze using Segment Replays.
  4. Set up mappings for your integration.
  5. Test your integration to ensure data is flowing smoothly between Braze and Segment.

Prerequisites

Requirement Origin Access Description
Segment Account & Account Information Segment https://app.segment.com/login You must have an active Segment Account to utilize their services with Braze.
Installed Source and Segment Source Libraries Segment https://segment.com/docs/sources/ The origin of any data sent into Segment, such as mobile apps, websites, or backend servers.

You must install the libraries into your app, site, or server before being able to set up a successful Source -> Destination flow.
Braze SDK Integration Braze For more details regarding Braze’s SDKs, please refer to our iOS, Android and Web documentation. Braze must be successfully installed onto your app or site.

Step 1: Configure Braze Settings in Segment

Destination Connection Settings After successfully setting up your Braze and Segment integrations individually, you’ll need to configure Braze as a destination from Segment. You’ll have many options to customize the flow of data between Braze and Segment using the connection settings described in the chart below.

Name Description
App Identifier Previously called the API Key. Found in the Developer Console under the API Settings tab.
REST API Key Previously called the “App Group Identifier”. Found in the Developer Console under the API Settings tab.
API Endpoint Find and enter your Braze SDK Endpoint in our documentation.

Format without the https as sdk.iad-01.braze.com.
Appboy Datacenter Your Braze cluster. Select and input your Braze Instance from the drop down.
Log Purchase when Revenue is present Choose when to log purchases.
Braze REST API Endpoint Find and enter your Braze REST Endpoint in our documentation. Make sure to include the https so it looks like https://rest.iad-01.braze.com.
Safari Website Push ID Safari requires a Website Push ID to send push. More on this here.
Braze Web SDK Version Which version of the Braze Web SDK you have integrated. You should have found this out during your initial integration process, but if you’re unsure, reach out to your account manager or Braze support.

Additional Connection Settings you might see during your integration.
Name Options Description
Allow Crawler Activity On/Off (True/False) Web Crawlers are automatic programs that visit websites, read then, and collect information that might be important for a search engine index. You can either allow or disallow this from your integrated web page or app. Braze disallows this by default.
Automatically Send In-App Messages On/Off (True/False) Braze automatically enables you to send push to your users upon proper integration.
Do Not Load Font Awesome On/Off (True/False) Braze uses FontAwesome for our in-app message icons, but you may disallow this feature at any time.
Enable HTML In-App Messages On/Off (True/False) Enables Braze platform users to write HTML in-app messages. More information in the JS Docs.
Enable Logging On/Off (True/False) Log to the JavaScript console by default.
Minimum Interval Between Trigger Actions In Seconds Any Number By default, trigger actions will only fire if 30 seconds have elapsed since the last trigger action.
Open In-App Messages in New Tab On/Off (True/False) By default, links from in-app message clicks load in the current tab or a new tab as specified in the Braze platform.
Open News Feed Cards in New Tab On/Off (True/False) By default, links from News Feed cards or Content Cards load in the current tab or a new tab as specified in the Braze platform.
Session Timeout In Seconds Any Number By default, sessions time out after 30 minutes of inactivity.
Track All Pages On/Off (True/False) Sends all Segment page calls to Braze as Page Events.
Track Only Named Pages On/Off (True/False) Sends all named Segment page calls to Braze
Update Existing Users Only On/Off (True/False) This only applies to Server Side integrations. This determines whether or not all users vs. existing users will be updated. This defaults to false.


Step 2A: Choose Integration Type and Implement

You can integrate Segment’s Web source (Analytics.js) and native client-side libraries with Braze using either a side-by-side (“Device-mode”) integration or a server-to-server (“Cloud-mode”) integration.

Integration Details
Side-by-Side / Device-mode Maps Segment’s SDK to Braze’s, allowing access to deeper features and more comprehensive usage of Braze than the server-to-server integration.
Server-to-Server / Cloud-mode Forwards data from Segment to Braze’s user/track endpoint.

Side-by-Side SDK Integration

Also called “Device-mode”, this integration maps Segment’s SDK and methods to Braze’s, allowing access to deeper features and more comprehensive usage of Braze than the server-to-server integration.

See and set up mappings to Segment’s SDK for Android on Braze’s Github.

To complete the side-by-side integration, please refer to Segment’s detailed instructions for Android.

See and set up mappings to Segment’s SDK for iOS on Braze’s Github.

To complete the side-by-side integration, please refer to Segment’s detailed instructions for iOS.

See and set up mappings to Segment’s SDK for Web / Analytics.js (Segment’s JavaScript SDK) on Braze’s Github.

For Braze’s Web SDK, Segment’s Analytics.js library dynamically pulls in and initializes our Web SDK when you add Braze as a destination on your Segment dashboard. However, to use Braze’s browser notification capabilities, please refer to Segment’s Web documentation.

Server-to-Server Integration

Also called “Cloud-mode”, this integration forwards data from Segment to Braze’s REST API.

This integration is only used in association with Segment’s server-side libraries, such as their Ruby or Go SDKs.

Enable the integration by setting your App Group’s REST API Key and Braze’s REST API endpoint for your corresponding data center (cluster) in your Connection Settings on Segment’s dashboard.

Similar to the side-by-side integration, you will need to map Segment methods to Braze.

Unlike the side-by-side integration, however, the server-to-server integration does not support any of Braze’s UI features, such as in-app messaging, News Feed, or push notifications.

Some automatically captured data is only available through the side-by-side integration. The following data is not available via the server-to-server integration:

  • Sessions
  • First Used App
  • Last Used App

Enabling Push Notifications

Currently, Braze’s server-to-server integration with Segment does not support methods for push tokens. In order to enable push notifications in Braze, you must import push tokens via the User Attribute Object of our User Data REST API. You can also rely on the side-by-side integration for push token capture and mapping.

Step 2B: Map Methods

Braze supports the Identify, Track, and Page (web) Segment methods; however, our REST APIs require you to include a user ID when making these calls. Braze also supports custom attribute mapping using Segment’s Group method.

Identify

When you identify a user, we will record information for that user with userId as the External User ID.

Segment Field Braze Field
firstName first_name
lastName last_name
birthday dob
avatar image_url
address.city home_city
address.country country
gender gender

All other traits will be recorded as custom attributes.

Segment Method Braze Method Example
segment > braze
Identify with User ID Set External ID analytics.identify(“dawei”); appboy.changeUser(“dawei”)
Identify with Reserved Traits Set User Attributes analytics.identify({email: “dawei@braze.com”}); appboy.getUser().setEmail(“dawei@braze.com”);
Identify with Custom Traits Set Custom Attributes analytics.identify({fav_cartoon: “Naruto”}); appboy.getUser().setCustomAttribute(“fav_cartoon”: “Naruto”);
Identify with User ID and Traits Set External ID and Attribute Combine methods above.

Group

When you call group in Segment, we will record a custom attribute with the name ab_segment_group_<groupId>, where groupId is the group’s ID in the method’s parameters. For example, if the group’s ID is 1234, then the custom attribute name will be ab_segment_group_1234. The value of the custom attribute will be set to true.

Track

When you track an event, we will record that event as a custom event using the name provided.

Segment Method Braze Method Example
segment > braze
Track Logged as a Custom Event. analytics.track("played_game"); > appboy.logCustomEvent("played_game");
Track with Properties Logged as Event Property. analytics.track("played_game", {name: "BotW", weapon: "boomerang"}); > appboy.logCustomEvent("played_game", { "name": "BotW", "weapon": "boomerang"});
Track with Product Logged as a Purchase Event. analytics.track("purchase", {products: [product_id: "ab12", price: 19]}); > appboy.logPurchase("ab12", 19);

Order Completed

When you track an event with the name Order Completed using the format described in Segment’s ECommerce API, we will record the products you’ve listed as purchases.

Page

The page call lets you record whenever a user sees a page of your website, along with any optional properties about the page.

Segment Method Braze Method Example
segment > braze
Page without name Logged as a Custom Event analytics.page(); > appboy.logCustomEvent("Loaded a Page");
Page with name Logged as a Custom Event analytics.page("Home"); > appboy.logCustomEvent("Viewed Home Page");

Step 3: Test Your Integration

Most of your Overview metrics (lifetime sessions, MAU, DAU, Stickiness, Daily Sessions, and Daily Sessions per MAU) will be blank even if Braze is receiving data from Segment.

You can view your data in the Custom Events or Revenue pages, or by creating a segment. The Custom Events page of the dashboard allows you to view custom event counts over time. Note that you will not be able to use formulas that include MAU and DAU statistics.

If you’re sending purchase data to Braze (see Order Completed), the Revenue page allows you to view data on revenue or purchases over specific periods of time or your app’s total revenue.

Creating a segment allows you to filter your users based on custom event data and custom attribute data.

User Deletion & Suppression

If you need to delete or suppress users, note that Segment’s User Delete feature is mapped to our Users/Delete endpoint. Please note that verification of these deletions could take up to 30 days.

You must ensure that that you select a common user identifier between Braze and Segment ( as in the user ID or external ID). Once you’ve initiated a deletion request with Segment, you will then be able to see the status and how it impacts each of your Destinations.

Segment Replays

Segment provides a service to clients to “Replay” all historical data to a new technology partner. New Braze customers who want to import all relevant historical data can do so through Segment.

Segment will connect to our Users Track endpoint to import user data into Braze on behalf of the client.

Best Practices

Review Use Cases To Avoid Data Overages.

Segment does not have a limit on the number of data elements clients send to them. Segment allows you to send all or turn on which events you will send to Braze. Rather than sending all of your events using Segment, we suggest that you review use cases with your marketing and editorial teams to determine which events you will send to Braze to avoid data overages.

Understand the Difference between ‘Custom API Endpoint’ vs ‘Custom REST API Endpoint’.
Braze Terminology Segment Equivalent
Braze SDK Endpoint Custom API Endpoint
Braze REST Endpoint Custom REST API Endpoint

Your Braze API Endpoint (called the “Custom API Endpoint” in Segment) is the SDK endpoint that Braze sets up for your SDK (for example, sdk.iad-03.braze.com). Your Braze REST API Endpoint (called the “Custom REST API Endpoint” in Segment) is the REST API Endpoint (for example, https://rest.iad-03.braze.com)

Ensure ‘Custom API Endpoint’ is Input into Segment Correctly.
Braze Terminology Segment Equivalent
Braze SDK Endpoint Custom API Endpoint
Braze REST Endpoint Custom REST API Endpoint

To ensure that you input your Braze SDK Endpoint correctly, the proper format must be followed. Your Braze SDK endpoint must not include https:// (for example, sdk.iad-03.braze.com), or else the Braze integration will break. This is required because Segment automatically prepends your endpoint with https://, resulting in Braze initializing with invalid endpoint https://https://sdk.iad-03.braze.com.

Ensure API Key is Input Correctly.

‘App Identifier’ vs. ‘REST API Key’

The ‘App Identifier’ is the App API Key found in the Manage Settings or Developer Console page on the Braze Dashboard. This field is necessary for SDK integrations to work. The ‘REST API Key’ is the dashboard REST API Key for making API calls. Make sure the key has permission to access users/track endpoint.

Certain Data Not Mapping to Braze.

Segment allows for different data types and structures, which can lead to issues where data will not pass from Segment to Braze as expected.

Scenarios where data will not pass as expected:

  1. Arrays or nested objects in event properties.
    • Segment allows for arrays or nested objects within the properties of their track events, which map to either Braze custom or purchase event properties. Since our properties don’t support those data types, we will silently reject those calls.
  2. Passing anonymous data server-to-server.
    • Customers may use Segment’s server-to-server libraries to funnel anonymous data to other systems.

Customization of Braze Initialization.

There are several different ways that Braze can be customized: push, in-app messages, Content Cards, and initialization. With a side-by-side integration you can still customize push, in-app messages, and Content Cards as you would with a direct Braze integration.

However, customizing when the Braze SDK is integrated or specifying initialization configurations may be difficult and sometimes not possible. This is because Segment will initialize the Braze SDK for you when the Segment initialization occurs.

WAS THIS PAGE HELPFUL?
New Stuff!