Skip to content

Commit a4004b4

Browse files
authored
Merge pull request #7677 from alecbatch/batch/destination
Batch documentation
2 parents 1e61450 + d307e4d commit a4004b4

File tree

6 files changed

+216
-90
lines changed

6 files changed

+216
-90
lines changed
324 KB
Loading
187 KB
Loading
62.3 KB
Loading
333 KB
Loading
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
title: Batch (Actions) Destination
3+
id: 596d11f870a3e552b957e6d9
4+
---
5+
6+
{% include content/plan-grid.md name="actions" %}
7+
8+
[Batch](https://batch.com/?utm_source=segmentio&utm_medium=docs&utm_campaign=partners){:target="_blank"} is a customer engagement platform for personalized, timely notifications and messages that boost retention and drive growth.
9+
10+
This destination is maintained by Batch. For any issues, [contact Batch Support](mailto:support@batch.com){:target="_blank"}.
11+
12+
## Getting started
13+
14+
1. From your workspace’s [destinations catalog](https://app.segment.com/goto-my-workspace/destinations/catalog){:target="_blank"}, search for **Batch**.
15+
2. Select **Batch (Actions)** and click **Add Destination**.
16+
3. Choose the **source** you want to connect to **Batch (Actions)**.
17+
4. In the [Batch dashboard](https://dashboard.batch.com/){:target="_blank"}, copy your **Project Key** and **REST API Key**.
18+
5. Paste the **Project Key** and **REST API Key** into the Batch destination settings in Segment.
19+
6. Toggle **Enable Destination**. Segment will start sending data to Batch according to your **Mappings**.
20+
21+
![Basic settings destination](./images/basic_settings_destination.png "Basic settings destination")
22+
23+
{% include components/actions-fields.html %}
24+
25+
## Profile attributes mapping
26+
27+
> info ""
28+
> If you’re new to the Identify call, see the [Segment spec](/docs/connections/spec/identify/) for more details.
29+
30+
When you call **Identify**, Segment maps `userId` to **`identifiers.custom_id`** and writes traits into **`attributes`**.
31+
32+
### Example Identify call (Segment input)
33+
34+
```js
35+
analytics.identify("97980cfea0067", {
36+
name: "Peter Gibbons",
37+
email: "peter@example.com",
38+
phone: "+33600000000",
39+
email_marketing: "subscribed",
40+
sms_marketing: "unsubscribed",
41+
plan: "premium",
42+
logins: 5
43+
}, {
44+
context: {
45+
timezone: "Europe/Paris",
46+
locale: "fr-FR"
47+
}
48+
});
49+
```
50+
51+
### Auto-mapped fields (native)
52+
53+
| Segment field | Batch field |
54+
|----------------------------------------|---------------------------------|
55+
| `userId` | `identifiers.custom_id` |
56+
| `traits.email` | `attributes.$email_address` |
57+
| `traits.phone` | `attributes.$phone_number` |
58+
| `traits.email_marketing` | `attributes.$email_marketing` |
59+
| `traits.sms_marketing` | `attributes.$sms_marketing` |
60+
| `context.timezone` | `attributes.$timezone` |
61+
| `context.locale` → language *(for example: `fr`)*| `attributes.$language` |
62+
| `context.locale` → region *(for example: `FR`)* | `attributes.$region` |
63+
64+
**Notes**
65+
66+
- `$email_marketing` / `$sms_marketing`: use `subscribed` / `unsubscribed`.
67+
- A locale like `fr-FR` is split into **language** (`fr`) and **region** (`FR`).
68+
- All other non‑reserved fields become **custom attributes** under `attributes` (strings, numbers, booleans, arrays of strings). Avoid arbitrary nested objects.
69+
70+
> info ""
71+
> For more details on the fields to be included, refer to the Batch [API Profile documentation](https://doc.batch.com/developer/api/cep/profiles/update){:target="_blank"}.
72+
73+
### Resulting Batch profile payload (output)
74+
75+
```json
76+
{
77+
"identifiers": {
78+
"custom_id": "97980cfea0067"
79+
},
80+
"attributes": {
81+
"$email_address": "peter@example.com",
82+
"$phone_number": "+33600000000",
83+
"$email_marketing": "subscribed",
84+
"$sms_marketing": "unsubscribed",
85+
"$language": "fr",
86+
"$region": "FR",
87+
"$timezone": "Europe/Paris",
88+
89+
"name": "Peter Gibbons",
90+
"plan": "premium",
91+
"logins": 5
92+
}
93+
}
94+
```
95+
96+
### Add custom mappings
97+
98+
To map additional traits into Batch profile attributes:
99+
100+
1. Open your destination → **Mappings****Edit Mapping**.
101+
2. Go to **Profile attributes****Add Mapping Field**.
102+
3. Choose a **source** (for example, `traits.plan`) and set a **target** under `attributes` (for example, `attributes.plan`).
103+
![Attributes mapping](./images/attributes_mapping.png "Attributes mapping")
104+
4. In **Step 4 – Send test record**, you can test your mapping before saving.
105+
![Test record](./images/test_record.png "Test record")
106+
5. **Save** and enable the mapping.
107+
108+
> info "Supported types"
109+
> Strings, numbers, booleans, arrays of strings are supported.
110+
> Avoid arbitrary nested objects.
111+
112+
## Historical backfill request
113+
114+
If you want to integrate your entire Segment userbase into Batch using the **Identify** method, you can request a historical backfill from Segment.
115+
116+
To do this:
117+
118+
1. **Contact Segment Support** at [friends@segment.com](mailto:friends@segment.com).
119+
2. **Request a historical replay** of your data.
120+
3. Provide Segment with the following details:
121+
- **Start date and time**
122+
- **End date and time** (usually “now”)
123+
- **Source**: the Segment source you want to replay
124+
- **Destination**: **Batch (Actions)**
125+
- **Events**: `Identify`
126+
127+
Segment will then replay your historical data so Batch can import your full userbase.
128+
129+
## Profile events mapping
130+
131+
When you call **Track**, Segment uses your `userId` as Batch’s **`identifiers.custom_id`**. A **userId is required** to attribute the event to a profile.
132+
133+
> info ""
134+
> For more details on the Track call, see the [Track spec](/docs/connections/spec/track).
135+
136+
### Example Track call (Segment input)
137+
138+
```js
139+
analytics.track("User Registered", {
140+
plan: "Pro Annual",
141+
accountType: "Facebook"
142+
}, {
143+
userId: "97980cfea0067"
144+
});
145+
```
146+
147+
### How Segment maps to Batch
148+
149+
| Segment | Batch |
150+
|-------------------|-------------------------|
151+
| `userId` | `identifiers.custom_id` |
152+
| `event` | `event.name` |
153+
| `properties.*` | `event.attributes.*` |
154+
155+
### Resulting Batch event payload (output)
156+
157+
```json
158+
{
159+
"identifiers": {
160+
"custom_id": "97980cfea0067"
161+
},
162+
"event": {
163+
"name": "User Registered",
164+
"attributes": {
165+
"plan": "Pro Annual",
166+
"accountType": "Facebook"
167+
}
168+
}
169+
}
170+
```
171+
172+
Events are sent to Batch in near real time according to your destination mappings, and all event `properties` are included under `event.attributes`.
173+
174+
![Events mapping](./images/events_mapping.png "Events mapping")
175+
176+
## Validation checklist
177+
178+
- Always send a stable `userId` → becomes `identifiers.custom_id`.
179+
- Place native profile fields under `attributes`: `$email_address`, `$email_marketing`, `$phone_number`, `$sms_marketing`, `$language`, `$region`, `$timezone`.
180+
- Put everything else under **custom attributes** in `attributes`.
181+
- Format dates using **ISO‑8601 UTC** (for example: `1989-07-20T00:00:00Z`).
182+
- Configure additional mappings in **Mappings → Edit Mapping**.
183+
- Test with a read-back or export to verify types, encodings, and timezones.
184+
185+
## Integrating a computed trait
186+
187+
> info ""
188+
> For more details on computed traits, see the [Segment spec](/docs/unify/Traits/computed-traits).
189+
190+
To integrate a computed trait with Batch:
191+
192+
1. Go to your **Segment workspace**.
193+
2. Open the **Engage** tab → **Destinations**.
194+
- If your Batch destination is already listed, skip this step.
195+
- Otherwise, click **Add destination** and select **Batch (Actions)**.
196+
3. Open the **Engage** tab → **Audiences****Computed traits**.
197+
4. Click **Create computed trait**.
198+
5. Configure your **calculation method** (for example: count, aggregation, last value).
199+
6. Click **Preview**, then **Next**.
200+
7. Select your **Batch destination**.
201+
8. Choose how to send the data:
202+
- For an attribute → enable **Send Identify** in the connection settings.
203+
- For an event → enable **Send Track**.
204+
9. Give your computed trait a **clear name**.
205+
206+
Segment will then automatically update and forward your computed trait data to Batch.
Lines changed: 10 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,21 @@
11
---
22
title: Batch Destination
3-
id: 596d11f870a3e552b957e6d9
43
---
5-
The Batch.com integration code is open sourced on GitHub. Feel free to check it out: [iOS](https://github.com/BatchLabs/ios-segment-integration){:target="_blank"}, [Android](https://github.com/BatchLabs/android-segment-integration){:target="_blank"}.
64

7-
## Getting Started
5+
{% include content/plan-grid.md name="actions" %}
86

9-
* Batch.com supports the `screen`, `track`, `identify` and `group` methods.
107

11-
* Make a Batch.com account.
12-
* Turn on Batch.com using Segment dashboard.
13-
* Enter your Batch LIVE API Key. You can find it in your dashboard, under 'settings'.
8+
Batch is a powerful customer engagement platform that helps businesses deliver personalized, timely notifications and messages to boost user retention and drive growth. Discover how Batch can transform your communication strategy at Batch.
149

15-
Events tracked using Segment's `track`/`screen` will automatically be tracked. `Identify` and `group` calls will also be mapped to Batch user data.
10+
This destination is maintained by Batch. For any issues with the destination, [contact their Support team](mailto:support@batch.com).
1611

17-
## Android
12+
## Getting started
1813

19-
### Installation
14+
1. From your workspace's [Destination catalog page](https://app.segment.com/goto-my-workspace/destinations/catalog){:target="_blank"} search for Batch.
15+
2. Select **Batch** and click **Add Destination**.
16+
3. Select an existing Source to connect to Batch (Actions).
17+
4. Go to the [Batch dashboard](https://dashboard.batch.com/){:target="_blank"}, find and copy the **Project Key** / **REST API Key**
18+
5. Enter the **Project Key** / **REST API Key** in the Batch destination settings in Segment.
2019

21-
Add the following dependency in your build.gradle:
2220

23-
```
24-
compile "com.batch.android:sdk-segment-integration:+"
25-
```
26-
27-
Import the integration:
28-
29-
```
30-
import com.segment.analytics.android.integrations.batch.BatchIntegration;
31-
32-
```
33-
34-
Then, add the factory to your Analytics instance:
35-
36-
```java
37-
Analytics analytics = new Analytics.Builder(this, "write_key")
38-
.use(BatchIntegration.getFactory(this))
39-
.build();
40-
```
41-
42-
43-
## iOS
44-
45-
### Installation
46-
47-
Add the following Cocoapods dependency:
48-
49-
```
50-
pod 'Segment-Batch'
51-
```
52-
53-
If you integrate in a Swift project or have `use_frameworks!` in your Podfile, you need to use the following to work around due to a limitation with Cocoapods:
54-
55-
```
56-
pod 'Batch'
57-
pod 'Segment-Batch/StaticLibWorkaround'
58-
```
59-
60-
Then, add the integration factory in your Analytics instance:
61-
62-
```objc
63-
#import <Segment-Batch/SEGBatchIntegrationFactory.h>
64-
65-
SEGAnalyticsConfiguration *config = [SEGAnalyticsConfiguration configurationWithWriteKey:@"MySegmentWriteKey"];
66-
[config use:[SEGBatchIntegrationFactory instance]];
67-
[SEGAnalytics setupWithConfiguration:config];
68-
```
69-
70-
## Server Side
71-
72-
You can transmit server-side data from Segment to Batch with a [destination function](/docs/connections/functions/destination-functions/). Follow the steps outlined [in Batch's documentation](https://help.batch.com/en/articles/2208243-how-to-connect-batch-to-segment){:target="_blank"} for a smooth integration.
73-
74-
## Screen
75-
76-
When you call `screen` in your mobile app, we send a screen view to an event named `SEGMENT_SCREEN`. The screen name will be tracked as the event's label.
77-
78-
## Identify
79-
80-
When you `identify` a user, we'll pass that user's information to Batch as the custom user identifier. Batch supports tracking anonymous users, but not through Segment's `anonymousId`.
81-
82-
Tracked events are attached to the installation ID, and the installation ID itself can be attached/detached to a user at a later date, with no data loss.
83-
84-
## Track
85-
86-
When you `track` an event, we will send that event to Batch after converting the name to fit Batch's event naming rules.
87-
88-
For example, an event named `Ad Shown` will become `AD_SHOWN`. Note that this means that event names longer than 30 characters will be truncated.
89-
The events `title` property will become the event's label.
90-
91-
## Group
92-
93-
When you call `group`, we will set the group ID in a user attribute named `SEGMENT_GROUP`.
94-
95-
## Features
96-
97-
All of our supported Segment integration features will work automatically, with no action or specific properties required on your side.
98-
99-
Batch's other features are available directly by using the native SDK, which comes bundled with this integration.
100-
101-
To use the Batch native SDK through Segment, follow the [instructions for Android](/docs/connections/sources/catalog/libraries/mobile/android/#how-can-i-use-a-destination-specific-feature) and [instructions for iOS](/docs/connections/sources/catalog/libraries/mobile/ios/#what-if-your-sdk-doesnt-support-feature-x).
21+
{% include components/actions-fields.html %}

0 commit comments

Comments
 (0)