Custom Dimensions
Add contextual data to your events with up to 10 custom dimensions per property.
Overview
Custom dimensions allow you to attach additional data to your analytics events. Each property supports 10 custom data slots (cd1-cd10) that can hold strings, numbers, or booleans.
Setting Custom Data
setCustomData()
// String value
alkeAnalytics.setCustomData(1, "category_tech");
// Number value
alkeAnalytics.setCustomData(2, 42);
// Boolean value
alkeAnalytics.setCustomData(3, true);
// Clear a dimension
alkeAnalytics.setCustomData(1, null);
| Parameter | Type | Description |
|---|---|---|
id | numberrequired | Dimension index (1-10) |
value | string|number|boolean|nullrequired | Value to store. Use `null` to clear. |
Late Values
Sometimes you don’t have all data available when the pageview starts. Use late values to update dimensions before the event is sent.
setLateCustomData()
For values resolved asynchronously:
// Promise-based late value
const userTypePromise = fetchUserType();
alkeAnalytics.setLateCustomData(1, userTypePromise);
// The value will be included when the pageview flushes
Consent-Wrapped Values (Web)
For GDPR compliance, wrap sensitive values so they’re only sent when consent is granted:
// Only sent if user consented to purpose 1 (store/access info)
alkeAnalytics.setCustomData(1,
alkeAnalytics.holdUntilConsent(email, null, [1])
);
// With fallback value
alkeAnalytics.setCustomData(2,
alkeAnalytics.holdUntilConsent(userId, "anonymous", [1, 9])
);
See Consent Management for more details.