# How to migrate from Heap to Pug

A step-by-step guide to migrating from Heap to Pug: inventory your Heap reports, stand up Pug, swap the SDK, dual-run during cutover, and rebuild your insights.

Source: https://pug.sh/guides/migrate-from-heap-to-pug

A practical path off Heap. Pug matches the autocapture-first core (trends, funnels, retention, flows, and profiles), open source and self-hostable. History doesn’t transfer between tools, so the playbook is to run both during cutover and switch once Pug covers the reports you rely on.

## What you’ll need

- A Pug deployment: self-hosted, or Pug Cloud (free up to 100k events a month)
- Access to your app’s tracking code (where Heap’s snippet/SDK lives)
- A short list of the Heap reports and events your team relies on

New to Pug? The [Pug vs Heap comparison](https://pug.sh/compare/heap-alternative) covers what matches and what doesn’t, and [Heap pricing, explained](https://pug.sh/learn/heap-pricing) covers why teams move.

## Six steps to migrate

1

### 1. Inventory what you use in Heap

Heap autocaptures far more than any team looks at. Before moving, list the reports, funnels, retention cohorts, and defined events your team genuinely relies on. That short list (not Heap’s full surface) is what you need to reproduce, and it keeps the migration small.

2

### 2. Stand up Pug

Self-host Pug (one Go binary on PostgreSQL, ClickHouse, NATS, and Dragonfly), or start free on Pug Cloud and run no servers. Both run the same code. Moving from Cloud to your own server later changes one SDK option, endpoint, but the events Cloud already holds stay there: there is no built-in migration between the two yet.

3

### 3. Swap the SDK and initialize

Where Heap’s snippet or SDK lives today, add the Pug Web, Android, iOS, or Flutter SDK and initialize it with your project ID and public key (plus endpoint, if you self-host); server-side calls move to the Node, Go, or Ruby SDK. On the web, autocapture (page views, clicks, scrolls, form submits, plus rage and dead clicks) starts immediately, so your baseline interactions are covered without re-instrumenting.

4

### 4. Recreate identify() and your key events

Call identify(userId) where you identify users in Heap so anonymous history merges into one profile, and add back the handful of custom events and traits your reports depend on. In the Web SDK’s default cookieless mode, identify() does nothing until the visitor consents, so wire your consent banner to optInTracking(). Standard, typed event names keep the data clean, and the tracking-plan generator can scaffold them.

5

### 5. Run Pug alongside Heap

Analytics history doesn’t transfer between tools, so dual-run. Pug starts collecting the day you install it; keeping both live for a few weeks builds up comparable history and lets you check Pug’s numbers against Heap’s before you trust them.

6

### 6. Rebuild your insights, then cut over

Recreate that short list of reports in Pug (trends, funnels, retention, user flows), and confirm they match. Once the dashboards your team relies on are covered, make Pug the source of truth and retire Heap. A private key reads your raw events back through the API from day one.

- [Self-hosting setup guide](https://pug.sh/guides/self-hosted-analytics-setup)
- [Web, Android, iOS, Flutter, Node, Go & Ruby SDKs](https://pug.sh/sdks)
- [Read the docs](https://docs.pug.sh)

## Before you migrate

### Can I import my Heap data into Pug?

No. There’s no direct importer, and analytics history doesn’t transfer between tools. Pug starts collecting the moment you install it. Keep Heap (or a warehouse export of it) read-only for historical reference, and dual-run so you build comparable history in Pug before switching.

### How long does migrating from Heap take?

Swapping the SDK is usually an afternoon, because autocapture covers your baseline interactions immediately. The real work is rebuilding the handful of reports you use and dual-running long enough to trust them: plan on a few weeks of overlap.

### Will I lose any data?

No. Your Heap data stays in Heap; adding Pug deletes nothing. Pug starts its own collection in parallel. Plan the overlap so you’re never blind during cutover.

### Is Pug a drop-in replacement for Heap?

No, and we won’t pretend otherwise. Pug matches Heap’s autocapture-first core (trends, funnels, retention, user flows, and unified profiles), but it doesn’t have retroactive event definition, session replay, or the wider Contentsquare suite. See the Pug vs Heap comparison for where each one wins.

### Do I have to self-host Pug?

No. Pug Cloud runs it for you: past the free allowance, its Pay as you go plan is $1 a month plus $20 per million events, falling in steps to $10 per million past 100M, with 5 years of history, so a month of 1M events costs $19.00 and a month of 10M costs $167.00. Seats, projects, and SSO cost nothing extra. Self-hosting is the same product, free under AGPL-3.0 with no plans or limits.
