Skip to main content
Ask your AI

Customer.io

Server Source code Package Beta

Server-side event delivery to Customer.io via the official customerio-node SDK. Tracks events with TrackClient.track(), manages identities with identify(), and supports the customer lifecycle: page views, device registration, suppress/unsuppress and profile merging. Transactional messaging via APIClient.sendEmail() / sendPush() does not deliver today (see Transactional messaging).

Where this fits

Customer.io is a server destination in the walkerOS flow:

Receives events server-side from the collector, resolves a `customerId` (or falls back to `anonymousId`), optionally fires `identify()`, then forwards the event to Customer.io for campaigns and broadcasts.

Installation​

npm install @walkeros/collector @walkeros/server-destination-customerio
import { startFlow } from '@walkeros/collector';
import destinationCustomerio from '@walkeros/server-destination-customerio';

await startFlow({
  destinations: {
    customerio: {
      code: destinationCustomerio,
      config: {
        settings: {
          siteId: 'YOUR_SITE_ID',
          apiKey: process.env.CUSTOMERIO_API_KEY,
        },
      },
    },
  },
});

Configuration​

This destination uses the standard destination config wrapper (consent, data, env, id, ...). For the shared fields see destination configuration. Package-specific fields live under config.settings and are listed below.

Settings​

PropertyTypeDescriptionMore
siteId*stringCustomer.io Site ID. Find it in Settings > Workspace Settings > API Credentials.
apiKey*stringCustomer.io API Key. Find it in Settings > Workspace Settings > API Credentials.
appApiKeystringApp API Key for transactional messaging (sendEmail/sendPush). Find it in Settings > Workspace Settings > API Credentials > App API Keys.
region'us' | 'eu'Data center region. Must match where your Customer.io workspace was created. Default: us.
timeoutintegerHTTP request timeout in milliseconds. Default: 10000.
customerIdstringwalkerOS mapping value path to resolve customerId from each event (like user.id).
anonymousIdstringwalkerOS mapping value path to resolve anonymousId from each event (like user.session).
identifyanyDestination-level identity mapping. Resolves to { email?, first_name?, ... } attributes. Fires identify() on first push and re-fires when values change.
* Required fields

Mapping​

Per-event rules under config.mapping. For the standard rule fields (consent, condition, data, batch, name, policy) see mapping.

PropertyTypeDescriptionMore
identifyanyPer-event identify attributes. Resolves to { email?, first_name?, ... }. Use with silent: true on login/identify events.
pageanyPer-event page view. Resolves to { url }. Calls trackPageView(), which sends only the url: other resolved fields are not sent. Needs a customerId. Use with silent: true.
destroybooleanPermanently delete person from Customer.io. Set true on delete events with silent: true.
suppressbooleanSuppress the person; unlike destroy, the id cannot be re-added. Set true with silent: true.
unsuppressbooleanUndo a suppress for the person. Set true with silent: true.
addDeviceanyRegister push device. Resolves to { deviceId, platform, data? }. Use with silent: true.
deleteDeviceanyRemove push device. Resolves to { deviceId, platform }. Use with silent: true.
mergeanyMerge duplicate profiles. Resolves to { primaryType, primaryId, secondaryType, secondaryId }. Use with silent: true.
sendEmailanySend transactional email. Resolves to { to, transactional_message_id, message_data?, identifiers? }. Requires appApiKey. Fails today: the SDK accepts only its own SendEmailRequest object, so the call fails with transport. Use with silent: true.
sendPushanySend transactional push. Resolves to { transactional_message_id, message_data?, identifiers? }. Requires appApiKey. Fails today: the SDK accepts only its own SendPushRequest object, so the call fails with transport. Use with silent: true.

Examples

Anonymous track

When no customer id is resolved the event is sent via trackAnonymous keyed by the session id.

Event
{
  "name": "product view",
  "data": {
    "id": "ers",
    "name": "Everyday Ruck Snack",
    "color": "black",
    "size": "l",
    "price": 420,
    "currency": "EUR"
  },
  "context": {
    "shopping": [
      "detail",
      0
    ]
  },
  "globals": {
    "pagegroup": "shop"
  },
  "custom": {
    "completely": "random"
  },
  "user": {
    "session": "s3ss10n"
  },
  "nested": [],
  "consent": {
    "functional": true
  },
  "id": "db22fb16c70f663d",
  "trigger": "load",
  "entity": "product",
  "action": "view",
  "timestamp": 1700000103000,
  "timing": 3.14,
  "source": {
    "count": 1,
    "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
    "type": "collector",
    "schema": "4"
  }
}
Out
trackClient.trackAnonymous("s3ss10n", {
  "name": "product view",
  "data": {},
  "timestamp": 1700000103
})

Default track

A walkerOS event is forwarded to Customer.io as a track call keyed by the user id.

Event
{
  "name": "product view",
  "data": {
    "id": "ers",
    "name": "Everyday Ruck Snack",
    "color": "black",
    "size": "l",
    "price": 420,
    "currency": "EUR"
  },
  "context": {
    "shopping": [
      "detail",
      0
    ]
  },
  "globals": {
    "pagegroup": "shop"
  },
  "custom": {
    "completely": "random"
  },
  "user": {
    "id": "us3r",
    "session": "s3ss10n"
  },
  "nested": [],
  "consent": {
    "functional": true
  },
  "id": "db22fb16c70f663d",
  "trigger": "load",
  "entity": "product",
  "action": "view",
  "timestamp": 1700000100000,
  "timing": 3.14,
  "source": {
    "count": 1,
    "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
    "type": "collector",
    "schema": "4"
  }
}
Out
trackClient.track("us3r", {
  "name": "product view",
  "data": {},
  "timestamp": 1700000100
})

Destination identify

With settings.identify mapping user.email, the destination fires a Customer.io identify call before the track, on the first push and again when the customer or the attributes change.

Event
{
  "name": "page view",
  "data": {
    "domain": "www.example.com",
    "title": "walkerOS documentation",
    "referrer": "https://www.walkeros.io/",
    "search": "?foo=bar",
    "hash": "#hash",
    "id": "/docs/"
  },
  "context": {
    "dev": [
      "test",
      1
    ]
  },
  "globals": {
    "pagegroup": "docs"
  },
  "custom": {
    "completely": "random"
  },
  "user": {
    "id": "us3r",
    "session": "s3ss10n",
    "email": "user@example.com"
  },
  "nested": [
    {
      "entity": "child",
      "data": {
        "is": "subordinated"
      }
    }
  ],
  "consent": {
    "functional": true
  },
  "id": "f0cc5f6fec3d8eeb",
  "trigger": "load",
  "entity": "page",
  "action": "view",
  "timestamp": 1700000104000,
  "timing": 3.14,
  "source": {
    "count": 1,
    "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
    "type": "collector",
    "schema": "4"
  }
}
Out
trackClient.identify("us3r", {
  "email": "user@example.com"
});

trackClient.track("us3r", {
  "name": "page view",
  "data": {},
  "timestamp": 1700000104
})

Destroy person

A user delete event permanently removes the person from Customer.io via trackClient.destroy.

Event
{
  "name": "user delete",
  "data": {
    "string": "foo",
    "number": 1,
    "boolean": true,
    "array": [
      0,
      "text",
      false
    ]
  },
  "context": {
    "dev": [
      "test",
      1
    ]
  },
  "globals": {
    "lang": "elb"
  },
  "custom": {
    "completely": "random"
  },
  "user": {
    "id": "us3r",
    "session": "s3ss10n"
  },
  "nested": [
    {
      "entity": "child",
      "data": {
        "is": "subordinated"
      }
    }
  ],
  "consent": {
    "functional": true
  },
  "id": "ca4dde72b4847043",
  "trigger": "test",
  "entity": "user",
  "action": "delete",
  "timestamp": 1700000107000,
  "timing": 3.14,
  "source": {
    "count": 1,
    "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
    "type": "collector",
    "schema": "4"
  }
}
Mapping
{
  "silent": true,
  "settings": {
    "destroy": true
  }
}
Out
trackClient.destroy("us3r")

Mapped properties

A data mapping transforms the event payload into Customer.io track properties for an order.

Event
{
  "name": "order complete",
  "data": {
    "id": "0rd3r1d",
    "value": 555,
    "currency": "EUR"
  },
  "context": {
    "shopping": [
      "complete",
      0
    ]
  },
  "globals": {
    "pagegroup": "shop"
  },
  "custom": {
    "completely": "random"
  },
  "user": {
    "id": "us3r",
    "session": "s3ss10n"
  },
  "nested": [
    {
      "entity": "product",
      "data": {
        "id": "ers",
        "name": "Everyday Ruck Snack",
        "color": "black",
        "size": "l",
        "price": 420
      },
      "context": {
        "shopping": [
          "complete",
          0
        ]
      },
      "nested": []
    },
    {
      "entity": "product",
      "data": {
        "id": "cc",
        "name": "Cool Cap",
        "size": "one size",
        "price": 42
      },
      "context": {
        "shopping": [
          "complete",
          0
        ]
      },
      "nested": []
    },
    {
      "entity": "gift",
      "data": {
        "name": "Surprise"
      },
      "context": {
        "shopping": [
          "complete",
          0
        ]
      },
      "nested": []
    }
  ],
  "consent": {
    "functional": true
  },
  "id": "235d0d7bd7a213f2",
  "trigger": "load",
  "entity": "order",
  "action": "complete",
  "timestamp": 1700000102000,
  "timing": 3.14,
  "source": {
    "count": 1,
    "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
    "type": "collector",
    "schema": "4"
  }
}
Mapping
{
  "name": "purchase",
  "data": {
    "map": {
      "order_id": "data.id",
      "value": "data.value",
      "currency": "data.currency"
    }
  }
}
Out
trackClient.track("us3r", {
  "name": "purchase",
  "data": {
    "order_id": "0rd3r1d",
    "value": 555,
    "currency": "EUR"
  },
  "timestamp": 1700000102
})

Rename event

A mapping rule renames the walker event to a Customer.io-specific event name such as purchase.

Event
{
  "name": "order complete",
  "data": {
    "id": "0rd3r1d",
    "currency": "EUR",
    "value": 462,
    "tax": 73.76,
    "shipping": 5.22,
    "total": 467.22
  },
  "context": {
    "shopping": [
      "complete",
      0
    ]
  },
  "globals": {
    "pagegroup": "shop"
  },
  "custom": {
    "completely": "random"
  },
  "user": {
    "id": "us3r",
    "session": "s3ss10n"
  },
  "nested": [
    {
      "entity": "product",
      "data": {
        "id": "ers",
        "name": "Everyday Ruck Snack",
        "color": "black",
        "size": "l",
        "price": 420
      },
      "context": {
        "shopping": [
          "complete",
          0
        ]
      },
      "nested": []
    },
    {
      "entity": "product",
      "data": {
        "id": "cc",
        "name": "Cool Cap",
        "size": "one size",
        "price": 42
      },
      "context": {
        "shopping": [
          "complete",
          0
        ]
      },
      "nested": []
    },
    {
      "entity": "gift",
      "data": {
        "name": "Surprise"
      },
      "context": {
        "shopping": [
          "complete",
          0
        ]
      },
      "nested": []
    }
  ],
  "consent": {
    "functional": true
  },
  "id": "235d0d7bd7a213f2",
  "trigger": "load",
  "entity": "order",
  "action": "complete",
  "timestamp": 1700000101000,
  "timing": 3.14,
  "source": {
    "count": 1,
    "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
    "type": "collector",
    "schema": "4"
  }
}
Mapping
{
  "name": "purchase"
}
Out
trackClient.track("us3r", {
  "name": "purchase",
  "data": {},
  "timestamp": 1700000101
})

Page view

A page view fires trackPageView instead of a generic track call. Customer.io receives only the URL: the SDK does not send the mapped referrer.

Event
{
  "name": "page view",
  "data": {
    "url": "https://example.com/pricing",
    "referrer": "https://google.com"
  },
  "context": {
    "dev": [
      "test",
      1
    ]
  },
  "globals": {
    "pagegroup": "docs"
  },
  "custom": {
    "completely": "random"
  },
  "user": {
    "id": "us3r",
    "session": "s3ss10n"
  },
  "nested": [
    {
      "entity": "child",
      "data": {
        "is": "subordinated"
      }
    }
  ],
  "consent": {
    "functional": true
  },
  "id": "f0cc5f6fec3d8eeb",
  "trigger": "load",
  "entity": "page",
  "action": "view",
  "timestamp": 1700000106000,
  "timing": 3.14,
  "source": {
    "count": 1,
    "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
    "type": "collector",
    "schema": "4"
  }
}
Mapping
{
  "silent": true,
  "settings": {
    "page": {
      "map": {
        "url": "data.url",
        "referrer": "data.referrer"
      }
    }
  }
}
Out
trackClient.trackPageView("us3r", "https://example.com/pricing", {
  "referrer": "https://google.com"
})

Suppress person

A user suppress event suppresses the person via trackClient.suppress; unlike destroy, the id cannot be re-added.

Event
{
  "name": "user suppress",
  "data": {
    "string": "foo",
    "number": 1,
    "boolean": true,
    "array": [
      0,
      "text",
      false
    ]
  },
  "context": {
    "dev": [
      "test",
      1
    ]
  },
  "globals": {
    "lang": "elb"
  },
  "custom": {
    "completely": "random"
  },
  "user": {
    "id": "us3r",
    "session": "s3ss10n"
  },
  "nested": [
    {
      "entity": "child",
      "data": {
        "is": "subordinated"
      }
    }
  ],
  "consent": {
    "functional": true
  },
  "id": "5b12bfbf993662cf",
  "trigger": "test",
  "entity": "user",
  "action": "suppress",
  "timestamp": 1700000108000,
  "timing": 3.14,
  "source": {
    "count": 1,
    "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
    "type": "collector",
    "schema": "4"
  }
}
Mapping
{
  "silent": true,
  "settings": {
    "suppress": true
  }
}
Out
trackClient.suppress("us3r")

Unsuppress person

A user unsuppress event lifts an earlier suppress for the person via trackClient.unsuppress.

Event
{
  "name": "user unsuppress",
  "data": {
    "string": "foo",
    "number": 1,
    "boolean": true,
    "array": [
      0,
      "text",
      false
    ]
  },
  "context": {
    "dev": [
      "test",
      1
    ]
  },
  "globals": {
    "lang": "elb"
  },
  "custom": {
    "completely": "random"
  },
  "user": {
    "id": "us3r",
    "session": "s3ss10n"
  },
  "nested": [
    {
      "entity": "child",
      "data": {
        "is": "subordinated"
      }
    }
  ],
  "consent": {
    "functional": true
  },
  "id": "6224835c45150aa1",
  "trigger": "test",
  "entity": "user",
  "action": "unsuppress",
  "timestamp": 1700000109000,
  "timing": 3.14,
  "source": {
    "count": 1,
    "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
    "type": "collector",
    "schema": "4"
  }
}
Mapping
{
  "silent": true,
  "settings": {
    "unsuppress": true
  }
}
Out
trackClient.unsuppress("us3r")

User login identify

A user login triggers only a Customer.io identify call with profile attributes, skipping the track.

Event
{
  "name": "user login",
  "data": {
    "email": "user@acme.com",
    "first_name": "Jane",
    "plan": "premium"
  },
  "context": {
    "dev": [
      "test",
      1
    ]
  },
  "globals": {
    "lang": "elb"
  },
  "custom": {
    "completely": "random"
  },
  "user": {
    "id": "us3r",
    "session": "s3ss10n"
  },
  "nested": [
    {
      "entity": "child",
      "data": {
        "is": "subordinated"
      }
    }
  ],
  "consent": {
    "functional": true
  },
  "id": "9a86958c2ac6cde9",
  "trigger": "test",
  "entity": "user",
  "action": "login",
  "timestamp": 1700000105000,
  "timing": 3.14,
  "source": {
    "count": 1,
    "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
    "type": "collector",
    "schema": "4"
  }
}
Mapping
{
  "silent": true,
  "settings": {
    "identify": {
      "map": {
        "email": "data.email",
        "first_name": "data.first_name",
        "plan": "data.plan"
      }
    }
  }
}
Out
trackClient.identify("us3r", {
  "email": "user@acme.com",
  "first_name": "Jane",
  "plan": "premium"
})

When it fails

  • no identity order complete: A order complete event without a customerId or anonymousId cannot be sent to Customer.io: the push fails with missing-input instead of counting as delivered. Reported as failed with code missing-input.
  • no identity page view: A page view event without a customerId or anonymousId cannot be sent to Customer.io: the push fails with missing-input instead of counting as delivered. Reported as failed with code missing-input.
  • no identity product view: A product view event without a customerId or anonymousId cannot be sent to Customer.io: the push fails with missing-input instead of counting as delivered. Reported as failed with code missing-input.
  • no identity user delete: A user delete event without a customerId or anonymousId cannot be sent to Customer.io: the push fails with missing-input instead of counting as delivered. Reported as failed with code missing-input.
  • no identity user login: A user login event without a customerId or anonymousId cannot be sent to Customer.io: the push fails with missing-input instead of counting as delivered. Reported as failed with code missing-input.
  • no identity user suppress: A user suppress event without a customerId or anonymousId cannot be sent to Customer.io: the push fails with missing-input instead of counting as delivered. Reported as failed with code missing-input.
  • no identity user unsuppress: A user unsuppress event without a customerId or anonymousId cannot be sent to Customer.io: the push fails with missing-input instead of counting as delivered. Reported as failed with code missing-input.

The quickstart sets no config.consent, so Customer.io receives every event, whatever consent the event carries. To send only events with consent, add consent: { marketing: true } to config, next to settings (with several keys listed, one granted key is enough). An event without that consent is skipped or queued, depending on the collector's consentDenied. Server flows built by the CLI skip it and count it in skipped. With startFlow it waits in the destination's queue by default: a later event that carries consent does not release it, and only a walker consent command does, which then sends the waiting events of every user at once. Pass consentDenied: 'skip' to startFlow to skip such events instead (see Gate a destination with consent and consent-denied events on a server).

Identity​

Identity is resolved automatically from each event: customerId defaults to user.id and anonymousId defaults to user.session. Customer.io requires a customerId or anonymousId per event. When customerId is missing, the destination automatically falls back to trackAnonymous() so anonymous visitor data is preserved.

Customer lifecycle​

Per-rule mapping settings control which lifecycle methods are called in addition to the default track():

Mapping SettingSDK CallUse For
identifyidentify()Login, signup, profile updates
pagetrackPageView()Page views (only the url is sent)
destroydestroy()Delete a person (the id can be re-added)
suppresssuppress()Delete a person and block the id from being re-added (unlike destroy)
unsuppressunsuppress()Allow a suppressed id to be re-added (the deleted person is not restored)
addDeviceaddDevice()Register push notification token
deleteDevicedeleteDevice()Remove push token
mergemergeCustomers()Consolidate duplicate profiles

Use silent: true on the rule to fire only the lifecycle call without tracking a second track() event.

Every lifecycle call needs a resolved customerId. addDevice and deleteDevice also need deviceId and platform, and merge needs all four of its fields. When a value is missing, the destination skips the call without an error. If the rule also sets silent: true, nothing is sent and the push still counts as delivered, as with a page rule on an anonymous visitor's page view.

Transactional messaging​

Set settings.appApiKey to call sendEmail / sendPush via Customer.io's App API from a mapping rule. These calls do not deliver today. The SDK accepts only its own SendEmailRequest and SendPushRequest objects, so every call fails with transport, logged at ERROR, and nothing is sent. Without appApiKey, a sendEmail or sendPush rule skips the call without an error.

💡 Need implementation support?
elbwalker offers hands-on support: setup review, measurement planning, destination mapping, and live troubleshooting. Book a 2-hour session (€399)