Create a Sync from ClickHouse to Batch Profile Events
Before you start
To create a ClickHouse → Batch Profile Events sync, you'll need:
Access to the Batch dashboard
A ClickHouse table or view containing one row per event
Your ClickHouse credentials (Host, Port, Database, Username, Password)
A table (or view) that follows the Cloud Sync events input format (see below)
1) Prepare your ClickHouse table or view
Cloud Sync expects your ClickHouse source (table or view) to include:
A profile identifier (to know which profile the event belongs to)
An event name (the type of event being recorded)
A cursor field (to know which rows are new since the last run)
Any number of event attribute columns (sent to Batch as event properties)
1.1 One row per event
Your source must contain one row per event.
Unlike profile attribute syncs, multiple rows can share the same custom_id — each row creates a separate event on the corresponding profile.
1.2 Required columns
Your table (or view) must include the following columns:
custom_id
✅
The identifier of the profile the event belongs to
event_name
✅
The name of the event (e.g. add_to_cart, purchase)
last_updated_at
✅
Cursor used for incremental sync
last_updated_at must be set at the time the event row is inserted and must not change afterwards. It is used only to determine which rows to fetch on the next sync run, not as the event timestamp.
1.3 Optional columns
event_time
The timestamp of the event, in RFC 3339 UTC format (e.g. 2026-04-17T04:25:00Z). If omitted, Batch uses the time of reception.
1.4 Event attribute naming rules (ClickHouse-compatible)
ClickHouse column names do not support characters like $, (, or ). Cloud Sync relies on prefixes in column names to represent typed event attributes.
Supported prefixes
date__
Date attribute
date__purchased_at
url__
URL attribute
url__item_url
Any column without a prefix is sent to Batch as a standard string, number, or boolean attribute.
1.5 Handling arrays
Array event attributes must be passed as a String column containing a stringified JSON array. Native ClickHouse Array() types are not supported.
Example:
1.6 Handling objects
Object event attributes must also be stringified as a JSON object before being passed to Cloud Sync. The connector parses the string and sends it in the correct format to the Profile API.
Example:
1.7 Example schema (e-commerce)
How this maps in Batch:
custom_ididentifies the profile the event is attached toevent_namesets the event typeevent_timesets the event timestamp (falls back to reception time if omitted)item,quantity,pricebecome standard event attributesurl__item_urlis interpreted as a URL attributedate__purchased_atis interpreted as a date attributeproduct_detailsis interpreted as an object attribute
1.8 Using a View
If your raw event table doesn't match the expected naming or format, create a ClickHouse View that converts your schema into the correct conventions.
This approach lets you:
rename fields with the correct prefixes (
date__,url__)set a reliable
last_updated_atbased on insertion timestringify array and object columns correctly
format
event_timeto RFC 3339 UTC
1.9 Handling nulls
If an optional column value is NULL, that attribute is simply omitted from the event. It does not affect other attributes on the same event or on the profile.
2) Create the Sync in the Batch dashboard
Cloud Sync is configured from the dashboard via a dedicated Sync module.
Open the Batch dashboard
Go to Data → Cloud Sync
Click Create Sync
Select ClickHouse as the source
2.1 Configure your ClickHouse connection
Enter the following fields:
Host
Your ClickHouse server hostname (e.g. your-host.example.com)
Port
ClickHouse HTTP(S) port — defaults to 8123
Database
The database containing your source table/view (default: default)
Username
Your ClickHouse username
Password
Your ClickHouse password
SSL
Toggle on to use a secure connection (recommended for production)
Table
The table or view name
Batch validates the connection before continuing.
2.2 Select the destination
In the Destination dropdown, select Batch > Profile events.
2.3 Configure event mapping
Cloud Sync applies a simple mapping model:
custom_id→ identifies which Batch profile to attach the event toevent_name→ sets the event typelast_updated_at→ used only for incremental sync logicall other columns → mapped to event attributes
3) How incremental sync works
Cloud Sync uses incremental processing, which means it does not re-import your full dataset at every run. Instead, it fetches only the rows that are new since the last successful sync.
3.1 The last_updated_at cursor
last_updated_at cursorBatch stores the last successful cursor value internally.
At each run, Batch fetches only rows where:
last_updated_atis greater than the last stored cursor
This makes sync runs faster, more scalable, and more cost-efficient.
For events, last_updated_at should reflect when the row was inserted into the table, not when the event occurred (event_time). Do not backfill or modify last_updated_at after insertion.
3.2 Inserts and deletes
Incremental syncs capture:
✅ new event rows (inserts)
They do not capture:
❌ deletions — events sent to Batch are immutable; they cannot be removed via Cloud Sync
3.3 Best practices for reliable incremental syncs
To avoid missing events:
Set
last_updated_atat insertion time and never modify it afterwardsUse a View if you need to rename columns or apply type conversions
Use
ReplacingMergeTreeand order bylast_updated_atfor large tables
4) Test and enable your Sync
Before enabling the schedule:
Run a test sync
Verify:
Events are created on the correct profiles
event_timeis set correctly (or defaults to reception time as expected)date__andurl__fields are interpreted correctlyArray and object attributes are correctly stringified
Once enabled, Batch automatically handles batching and retries.
Last updated

