CDPs and tag managers

Routing Segment, RudderStack, Google Tag Manager and Zapier into a Project with our own destination function, transformation, tag template and Zapier app.

If your events already flow through a customer data platform or a tag manager, you do not need to instrument anything twice. We ship a connector of our own for each of the four: a Segment destination function, a RudderStack transformation, a Google Tag Manager tag template and a Zapier app. All four live in this repository under integrations/, all four post to the same routes as our SDKs, and events arriving this way are indistinguishable from events sent by one.

Status

Note

Each connector works today when you install it yourself, with the steps below. Listing them in the vendors' own catalogues (Segment's destination catalogue, the GTM Community Template Gallery, the Zapier app directory) is a separate submission process that has not been done, so for now you paste or import the file rather than picking us from a list.

Which credential

Never put a Server key in a web container or a device-mode setting: it can read every report in the Project.

Segment

Our connector is a destination function: one file, no package installs, running in Segment's own runtime.

  1. Segment, then Connections, then Functions, then New function, then Destination.
  2. Paste integrations/segment-destination/index.js. Delete the final export { … } line if the editor objects to it; it exists only so the mapping can be tested locally.
  3. On the Settings tab add projectToken (String, encrypted, required) and, if the function should be a trusted writer, serverKey (String, encrypted). host and groupKey are optional.
  4. Connect the function to a source and send a test event.

What it maps:

Notes that save a debugging session:

  • messageId is the idempotency key. The function maps it to our id, so a Segment replay writes nothing twice.
  • It throws RetryError on 429 and 5xx. That is what makes Segment retry rather than drop.
  • groupKey is one setting, and a Project may use several group keys. Run a second function, or set the key per source, if you group by more than one thing.
  • Historical replays through a function are clamped to the last 24 hours like any other /v1/ingest write unless the function is using a Server key. For real history use /v1/import.

Test the mapping locally before you paste it: node --test integrations/segment-destination/index.test.js.

RudderStack

RudderStack has no first-party destination for us, so our connector is a transformation attached to a Webhook destination. The transformation returns the ingest batch body, which leaves RudderStack owning retries, queuing and delivery stats.

  1. Destinations, then Webhook: URL https://t.intelligent.page/v1/ingest, method POST, header content-type: application/json, plus either x-analytics-token: ipa_pub_… or authorization: Bearer ipa_sec_….
  2. Transformations, then New, then paste integrations/rudderstack-destination/index.js, then connect it to that destination.

transformEvent handles one message; transformBatch chunks at the contract's 50 events per call. The mapping matches the Segment function exactly, page becoming $pageview and the identity calls becoming the reserved events. A message with neither userId nor anonymousId is dropped by returning undefined, RudderStack's own convention, rather than being rejected downstream.

Test locally: node --test integrations/rudderstack-destination/index.test.js.

Google Tag Manager

integrations/gtm-template/ is our own web tag template. Import it into your container with Templates, then New, then the overflow menu, then Import, and select template.tpl.

Its fields:

The tag injects no library and sends one pixel, so it costs one request and nothing on the main thread. A GTM web template may only send a pixel, which is why the tag posts to the compatibility endpoint /mixpanel/track with a base64 data= parameter rather than to /v1/ingest: that is an internal transport detail of our template, not a separate integration. The anonymous visitor id lives in the first-party ip_aid cookie, the same one the web SDK uses, so a visitor seen by both is one person.

A custom HTML tag instead, when you want the exact event shape:

<script>
  (function () {
    var e = {
      id: (crypto.randomUUID ? crypto.randomUUID() : String(Date.now()) + Math.random()),
      ts: new Date().toISOString(),
      event: {{Event Name}},
      aid: {{Anon Id}},
      path: location.pathname,
      url: location.href,
      ref: document.referrer || undefined,
      props: { value: {{Value}} }
    };
    var body = JSON.stringify({ v: 1, token: 'ipa_pub_REPLACE_ME', events: [e] });
    navigator.sendBeacon(
      'https://t.intelligent.page/v1/ingest',
      new Blob([body], { type: 'text/plain' })
    );
  })();
</script>

The token is in the request body because sendBeacon cannot set headers; that is exactly why the body form exists. Keep {{Anon Id}} as a variable reading the same ip_aid value your site's own client uses, or GTM events will arrive as a different visitor from everything else.

A server-side GTM container should use a Server key and post to /v1/ingest with the bearer header instead.

Zapier

integrations/zapier/ is a Zapier CLI app with two actions, Track Event and Identify User, authenticated with a Server key. There are no triggers on purpose: Zapier triggers poll, and reading data out belongs to the API and the warehouse export.

The app has not been pushed to Zapier yet, so until it is in the directory the working path is the built-in Webhooks by Zapier action:

  • Action: POST
  • URL: https://t.intelligent.page/v1/ingest
  • Headers: Content-Type: application/json, Authorization: Bearer ipa_sec_…
  • Data pass-through: off
  • Body (as JSON):
{
  "v": 1,
  "events": [{
    "id": "{{zap_meta_human_now}}-{{id}}",
    "ts": "{{zap_meta_utc_iso}}",
    "event": "Form Submitted",
    "did": "{{email}}",
    "source": "server",
    "props": { "form": "contact" }
  }]
}

Build id from something stable in the trigger record, not from the time alone: if the Zap re-runs, a stable id means the event is not counted twice. Our app does this for you, deriving the id from the Zap id, the person, the event name and the timestamp, and it lets you supply a source record id instead. Its connection test posts an empty batch, so pressing Test proves the key without writing a fake event.

Test locally: node --test integrations/zapier/index.test.js.

Verify any of them

curl -N https://t.intelligent.page/v1/live -H 'Authorization: Bearer ipa_sec_REPLACE_ME'

Fire a test event from the tool with that stream open. Check three things in the frame: the event name, the did (it must be the same id namespace your other sources use), and the source.

Double counting

The commonest failure with a CDP is not a broken pipe, it is two working ones. If you install both a browser client and a Segment destination, a page view arrives twice under different ids and every report is wrong in a way that looks plausible.

Pick one path per event type. A useful split: page views and clicks from the browser, purchases and subscription changes from the server or the CDP, where they are authoritative.

Next