Working with data warehouse
Contents
This is an internal guide to setting up and working with the data warehouse for PostHog engineers. If you're a PostHog user, check out our data warehouse docs instead.
Apple Ads in Marketing analytics
Marketing analytics support is controlled by the boolean organization flag marketing-analytics-apple-ads and is off by default.
Enable the flag for an organization to show the integration and include its data in live and precomputed marketing queries.
Disable it to stop using the integration in Marketing analytics without deleting the connection or its imported data.
Data warehouse syncs continue independently of this flag.
Sync campaigns and campaign_report to include Apple Ads in Marketing analytics.
Sync ad_groups and ad_group_report to enable the ad group breakdown.
Apple Ads does not provide an ad-level report through this connector.
Taps appear as clicks, and installs appear as reported conversions.
The adapter accepts both Campaign Management API 5 installs and Ads Platform API totalInstalls, including tables that contain rows from both versions.
Spend uses the currency in Apple's localSpend object and the reporting date to convert into the project's currency.
Apple does not report conversion revenue through these reports, so reported conversion value is zero.
OpenAI Ads in Marketing analytics
Marketing analytics support is controlled by the boolean organization flag marketing-analytics-openai-ads and is off by default.
Enable the flag for an organization to show the integration and include its data in live and precomputed marketing queries.
Disable it to stop using the integration in Marketing analytics without deleting the connection or its imported data.
Data warehouse syncs continue independently of this flag.
Sync campaigns and campaign_insights to include OpenAI Ads campaign delivery in Marketing analytics.
Spend is already in major currency units; the importer adds currency_code from the account metadata so reports can convert spend at each bucket date.
Existing connections need a full resync of campaign_insights to populate currency on historical rows.
Cost tiles are unavailable without the currency column; queries with empty historical currency values stop with a resync message.
Reported conversions and revenue are zero because the importer currently requests delivery metrics only.
Ad groups and individual ads are not included in the native integration.
Amazon Ads in Marketing analytics
Marketing analytics support is controlled by the boolean organization flag marketing-analytics-amazon-ads and is off by default.
Enable the flag for an organization to show the integration and include its data in live and precomputed marketing queries.
Disable it to stop using the integration in Marketing analytics without deleting the connection or its imported data.
Data warehouse syncs continue independently of this flag.
Sync sp_campaigns and sp_campaign_reports to include Sponsored Products campaigns in Marketing analytics.
Spend uses cost, with currency conversion at each report date using campaign_budget_currency_code.
Reported conversions and revenue use the 14-day purchase and sales metrics; the other attribution windows are not added to these totals.
Sponsored Brands, Sponsored Display, ad groups, and individual ads are not included because the importer does not provide their performance reports.
Monetary tiles require the report date and currency columns; reports without currency can still supply impressions and clicks.
Adding a new source
Looking to add a new source to data warehouse? We have a detailed guide in the codebase.
If you're a customer of PostHog Cloud and are looking to import data into your project, then you're likely looking for this section of the docs instead
Selecting a source in the Advertising category records Marketing analytics product intent as well as Data warehouse intent.
This happens when the user selects the connector, before credentials are validated or data syncs.
The category covers new advertising connectors automatically; it does not mean Marketing analytics supports their data natively.
Selecting a source outside this category, such as BigQuery, records only Data warehouse intent.
Supported self-managed providers keep their separate Marketing analytics intent tracking.
Importing your local Postgres instance
- Head to the new source flow in your local app, hit the link button next to Postgres
- Use the following settings:
- host = 127.0.0.1
- port = 5432
- database = posthog
- user = posthog
- password = posthog
- schema = public
- Hit next, then select which tables you'd like to import. More info on the sync types can be found here. For the Postgres-specific
xmin(cursorless incremental) sync type and its limitations, see the Postgres source README - Hit next and finish the import -
temporal-worker-data-warehousewill then import the data into your local object storage
Accessing object storage
All your data warehouse data is stored in your local object storage (SeaweedFS, S3-compatible, running at http://localhost:19000). Unlike MinIO, SeaweedFS has no web console, so inspect it with any S3 client. For example, with the AWS CLI:
There's a separate folder under the data-warehouse bucket for each table you sync.
Setting up a MySQL source
If you want to set up a local MySQL database as a source for the data warehouse, there are a few extra set up steps you'll need to complete:
First, install MySQL:
Once MySQL is installed, create a database and table, insert a row, and create a user who can connect to it:
To verify everything is working as expected:
- Navigate to "Data pipeline" in the PostHog application.
- Create a new MySQL source using the settings above (username and password both being
posthog) - Once the source is created, click on the "MySQL" item. In the schemas table, click on the triple dot menu and select the "Reload" option.
After the job runs, clicking on the synced table name should take you to your data.
Working with a MS SQL source
You'll need to install MS SQL drivers for the PostHog app to connect to a MS SQL database. Learn the entire process in posthog/warehouse/README.md. Without the drivers, you'll get the following error when connecting a SQL database to data warehouse: