From 3a9a996669aac7a8215cd2eec59d9d6aee8183e9 Mon Sep 17 00:00:00 2001 From: Ian Vanagas <34755028+ivanagas@users.noreply.github.com> Date: Tue, 16 Jul 2024 16:00:23 -0700 Subject: [PATCH 1/2] mixpanel migrate --- .../docs/migrate/migrate-from-amplitude.mdx | 2 +- .../migrate/mixpanel.mdx} | 64 ++++++++++--------- src/navs/index.js | 4 ++ vercel.json | 1 + 4 files changed, 40 insertions(+), 31 deletions(-) rename contents/{tutorials/mixpanel-to-posthog.md => docs/migrate/mixpanel.mdx} (55%) diff --git a/contents/docs/migrate/migrate-from-amplitude.mdx b/contents/docs/migrate/migrate-from-amplitude.mdx index 009d7ef64d49..16bc2036884b 100644 --- a/contents/docs/migrate/migrate-from-amplitude.mdx +++ b/contents/docs/migrate/migrate-from-amplitude.mdx @@ -10,7 +10,7 @@ import MigrationWarning from "./_snippets/migration-warning.mdx" Migrating from Amplitude is a two step process: -1. Export your data from Amplitude using the [Amplitude Export API](https://amplitude.com/docs/apis/analytics/export). +1. Export your data from Amplitude using the organizations settings export, [Amplitude Export API](https://amplitude.com/docs/apis/analytics/export), or the S3 export. 2. [Import data into PostHog](/docs/migrate) using PostHog's [Python SDK](/docs/libraries/python) or [`batch` API](/docs/api/capture) with the `historical_migration` option set to `true`. Other libraries don't support historical migrations yet. diff --git a/contents/tutorials/mixpanel-to-posthog.md b/contents/docs/migrate/mixpanel.mdx similarity index 55% rename from contents/tutorials/mixpanel-to-posthog.md rename to contents/docs/migrate/mixpanel.mdx index 854918905856..683f09466272 100644 --- a/contents/tutorials/mixpanel-to-posthog.md +++ b/contents/docs/migrate/mixpanel.mdx @@ -1,19 +1,16 @@ --- -title: How to migrate from Mixpanel to PostHog -date: 2023-03-03 -author: - - ian-vanagas -showTitle: true +title: Migrate from Mixpanel to PostHog sidebar: Docs -tags: - - configuration - - events - - product os +showTitle: true --- -PostHog is a great [alternative to Mixpanel](/blog/best-mixpanel-alternatives), especially if you want to replace other tools for session replay and A/B testing. +import MigrationWarning from "./_snippets/migration-warning.mdx" + + -In this tutorial, we'll walk through how to pull, format, and ingest data from Mixpanel into PostHog. +PostHog is a great alternative to Mixpanel, especially if you want to replace other tools for session replay and A/B testing. + +These docs walk you through pulling, formatting, and ingesting data from Mixpanel into PostHog. > Curious about the similarities and differences between the two platforms? Read our comparison of [PostHog vs Mixpanel](/blog/posthog-vs-mixpanel). @@ -23,17 +20,16 @@ To get started, you'll need both a Mixpanel account with data and a PostHog inst To start with, log in to Mixpanel and go to the project with the data you want to migrate. -1. Create a service account. Go to "Organization Settings," click the "Service Accounts" tab, click the "Add Service Account" button, enter a name, then click "Create." +1. Create a service account. Go to **Organization Settings**, click the **Service Accounts** tab, click the **Add Service Account** button, enter a name, then click **Create**. 2. Hold on to the **username** and **secret** for now. -3. You also need your **Project ID** which you can get from your "Project Settings." +3. You also need your **Project ID** which you can get from your **Project Settings**. ![Mixpanel](https://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/tutorials/mixpanel-to-posthog/mixpanel.png) Next, get the details for PostHog. -1. Get your **project API key** from the getting started flow or your project settings. -2. Create a **personal API key**. Go to your account settings (click the photo in the top right corner, then the gear next to your email), click the "Create personal API key" button, add a name, and press save. -3. Finally, note your **API host** (either `https://us.i.posthog.com` or `https://eu.i.posthog.com` or a custom domain) +1. Get your **project API key** from the getting started flow or [your project settings](https://us.posthog.com/settings/project). +2. Finally, note your **API host** (either `https://us.i.posthog.com` or `https://eu.i.posthog.com` or a custom domain) With all this, we are ready to set up the migration tool. @@ -41,15 +37,20 @@ With all this, we are ready to set up the migration tool. > **Note:** The Mixpanel to PostHog migration tool is a community-built tool. Test for yourself and use at your own risk. -Go to the [Mixpanel to Posthog Data Migrator repository](https://github.com/stablecog/mixpanel-to-posthog) and [clone the repo](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository). Once done, go to the newly created `mixpanel-to-posthog` folder, create a `.env` file, and add the details you collected. +Go to the [Mixpanel to Posthog Data Migrator repository](https://github.com/stablecog/mixpanel-to-posthog) and [clone the repo](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository). + +```bash +git clone https://github.com/stablecog/mixpanel-to-posthog.git +``` + +Once done, go to the newly created `mixpanel-to-posthog` folder, create a `.env` file, and add the details you collected. In our example, that is: ``` -MIXPANEL_USERNAME=ian.a2b789.mp-service-account +MIXPANEL_USERNAME=posthog-migrate.a2b789.mp-service-account MIXPANEL_PASSWORD=fCPFrpZYdzB9nlZ9kqabZcXuxSLKhjld MIXPANEL_PROJECT_ID=2880604 POSTHOG_PROJECT_KEY= -POSTHOG_API_KEY=phx_lz19ZGZWrVcwZol6qLmIvHBBHzc9lQbvN8b3U2zVufZ POSTHOG_ENDPOINT= ``` @@ -59,7 +60,7 @@ Next, in the terminal, make sure you have [installed Go](https://go.dev/doc/inst go run . ``` -This triggers some prompts about Mixpanel’s API URL, dates (to avoid rate limits and system crashes), and any data you missed. This should look like this: +This triggers prompts about Mixpanel's API URL, dates (to avoid rate limits and system crashes), and any data you missed. This should look like this: ![Script](https://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/tutorials/mixpanel-to-posthog/script.png) @@ -67,18 +68,21 @@ Once successful, you can find your new data in your PostHog instance. ![PostHog](https://res.cloudinary.com/dmukukwp6/image/upload/v1710055416/posthog.com/contents/images/tutorials/mixpanel-to-posthog/posthog.png) +> **Importing users:** The tool also includes the ability to migrate users from Mixpanel to PostHog. To do this, go to Mixpanel, select all columns, all users, get a `.csv` file, and then run the tool with the `-users-csv-file` flag: +> ```bash +> go run . -users-csv-file /path/to/users-export.csv +> ``` + ## What the tool is doing If you are interested in writing your own script, or just want to learn more about how Mixpanel and PostHog work, here is what the tool is doing: 1. Load the details from the `.env` file and prompt for any missing details (like date range). -2. Make `GET` requests to the Mixpanel API using the details. -3. Decode and format the response data from Mixpanel to one for PostHog. For example, change `Pageview` to `$pageview` and parse the properties. -4. Return a "[slice](https://go.dev/tour/moretypes/7)" of formatted `MixpanelDataLine` instances. Basically, a list of formatted event objects ready to import into PostHog. -5. Loop through the "slice" of formatted `MixpanelDataLine` instances and use the PostHog Client (set up with the `.env` details) to capture events. - -## Further reading - -- [What to do after installing PostHog in 5 steps](/tutorials/next-steps-after-installing) -- [Calculating average session duration, time on site, and other session-based metrics](/tutorials/session-metrics) -- [Get feedback and book user interviews with site apps](/tutorials/feedback-interviews-site-apps) +2. Make `GET` requests to the Mixpanel export API using the details. +3. Decode and format the response data from Mixpanel to one for PostHog. Although Mixpanel's schema is similar, there are many conversions needed to convert to PostHog's Schema. These include: + - Changing event names like `$mp_web_page_view` to `$pageview`, + - Changing event properties like `current_url_path` to `$pathname` + - Dropping some Mixpanel specific properties + - Formating the `distinct_id` depending on if it is the `$device_id` or not +4. Return a [slice](https://go.dev/tour/moretypes/7) of formatted `MixpanelDataLine` instances. Basically, a list of formatted event objects ready to import into PostHog. +5. Loop through the "slice" of formatted `MixpanelDataLine` instances and use the PostHog Client (set up with the `.env` details) to capture events. \ No newline at end of file diff --git a/src/navs/index.js b/src/navs/index.js index 39eaa269bb78..2c6427942b25 100644 --- a/src/navs/index.js +++ b/src/navs/index.js @@ -1845,6 +1845,10 @@ export const docsMenu = { name: 'Migrate from Amplitude', url: '/docs/migrate/migrate-from-amplitude', }, + { + name: 'Migrate from Mixpanel', + url: '/docs/migrate/mixpanel', + }, ], }, { diff --git a/vercel.json b/vercel.json index b2bae423cbe4..5cd94e9910c7 100644 --- a/vercel.json +++ b/vercel.json @@ -1131,6 +1131,7 @@ "source": "/docs/migrate/export-events", "destination": "/docs/cdp/common-questions#why-cant-i-use-the-ui-or-events-api-to-export-data" }, + { "source": "/tutorials/mixpanel-to-posthog", "destination": "/docs/migrate/mixpanel" }, { "source": "/blog/categories/ceo-diaries", "destination": "/blog/ceo-diaries" }, { "source": "/blog/categories/engineering", "destination": "/blog/engineering" }, { "source": "/blog/categories/inside-posthog", "destination": "/blog/inside-posthog" }, From a02431eb5cd6f5046259bdc182b6a98d9bb1df05 Mon Sep 17 00:00:00 2001 From: PostHog Date: Tue, 16 Jul 2024 23:03:18 +0000 Subject: [PATCH 2/2] Fix typos --- contents/docs/migrate/mixpanel.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/docs/migrate/mixpanel.mdx b/contents/docs/migrate/mixpanel.mdx index 683f09466272..ed90c71a4525 100644 --- a/contents/docs/migrate/mixpanel.mdx +++ b/contents/docs/migrate/mixpanel.mdx @@ -83,6 +83,6 @@ If you are interested in writing your own script, or just want to learn more abo - Changing event names like `$mp_web_page_view` to `$pageview`, - Changing event properties like `current_url_path` to `$pathname` - Dropping some Mixpanel specific properties - - Formating the `distinct_id` depending on if it is the `$device_id` or not + - Formatting the `distinct_id` depending on if it is the `$device_id` or not 4. Return a [slice](https://go.dev/tour/moretypes/7) of formatted `MixpanelDataLine` instances. Basically, a list of formatted event objects ready to import into PostHog. 5. Loop through the "slice" of formatted `MixpanelDataLine` instances and use the PostHog Client (set up with the `.env` details) to capture events. \ No newline at end of file