At a glance: Dynamic Query lets you run your own SQL queries directly on your Data Collaboration Platform (DCP) data. Query your own data, your own AF attribution data, or data shared inside a collaboration, to answer specific questions without setting up a report.
About Dynamic Query
Dynamic Query gives you the ability to run ad hoc, custom queries on your DCP data in real time to answer your specific collaboration questions quickly and efficiently.
- Let a collaborator better segment your data before they create an audience.
- Build your own campaign measurement logic with Dynamic Query.
Dynamic Query works differently depending on whether you are querying your own data or data shared in a collaboration.
Before you start
Before you can run any query, configure your cloud bucket destination. This step is required, because every query runs against your own cloud bucket and writes results directly to your storage. AppsFlyer does not store your query results, so your data stays within your own cloud environment.
Run a query on your own data
The following sections cover how to access and query data you own.
Access Dynamic Query
This is a separate area from collaboration-based querying below. The Sources panel here only lists sources you own, you cannot add a collaborator's source in this view.
- In AppsFlyer, go to the side menu > Collaborate > Data Clean Room.
- Select the Dynamic Query tab.
Write your query
-
Browse the source's fields in the Sources panel. Click a field to preview its distinct values.
Note
This helps your filters match real data before you write the query. For more information, see Data Collaboration Platform (DCP) - Create and manage sources.
-
Write your query freely, at raw level or aggregated, your choice. Every source here belongs to you, so there's no permission check and no GROUP BY requirement.
Note
If you are also an AppsFlyer client, you can query your AF attribution data this way too, but results are aggregated only, even though it is your own data.
Run a query with collaboration data
The following sections cover how to access and query data shared with you in a collaboration.
Access Dynamic Query in a collaboration
- In AppsFlyer, go to the side menu > Collaborate > Data Clean Room.
- Select the Collaborations tab, then select the relevant collaboration.
- Select the Dynamic Query tab.
When you query data shared in a collaboration, Dynamic Query can access every source added to that collaboration.
Write your query
-
Browse the source's fields in the Sources panel. Click a field to preview its distinct values.
Note
This helps your filters match real data before you write the query. For more information, see Data Collaboration Platform (DCP) - Create and manage sources.
-
Check the source's permission type. There are two permission types:
Permission type Join required? Result level Intersected Yes, you must join to your own source Aggregated only All Data No, you can query it freely Aggregated only Note
This determines whether your query needs a join. For more information, see Data Collaboration Platform (DCP) sharing permissions.
-
Write your query with a GROUP BY clause or an aggregate function, such as
COUNT(*).Important
A source you do not own always returns aggregated results, no matter which permission type it is shared under. Raw-level results stay available only for sources you own.
Privacy and query restrictions
Dynamic Query applies privacy protections at multiple levels:
-
Non-owned sources always return aggregated results, see "Run a query with collaboration data" above.
- Key-type identifier fields, such as AppsFlyer ID, Android ID, and IDFA (Identifier for Advertisers), always return as hashed values in query results.
- Distinct values are not available for fields categorized as Keys, such as AppsFlyer ID or Android ID, when browsing the Sources panel.
Explore sample queries
The following examples show how each permission type works in practice.
Find brand collaboration candidates
This query uses the All Data permission to find the top brands in a collaboration by client count and revenue over the last 60 days.
SELECT
t.brand_name,
COUNT(DISTINCT t.hashed_email) AS total_clients,
COUNT(*) AS total_purchases,
SUM(t.revenue) AS total_revenue
FROM <collaborator_transactions_table> t
WHERE t.event_time BETWEEN DATE_SUB(current_date(), 60) AND current_date()
GROUP BY t.brand_name
ORDER BY total_revenue DESC
LIMIT 20;
Build a loyalty club retargeting segment
This query uses the Intersected permission. It joins your own loyalty club data to a collaborator's purchase data, by country, over the last 30 days.
SELECT
t.country,
COUNT(DISTINCT l.hashed_email) AS loyalty_members,
COUNT(*) AS total_purchases,
SUM(t.revenue) AS total_revenue
FROM <collaborator_transactions_table> t
JOIN <my_loyalty_club_table> l ON l.hashed_email = t.hashed_email -- required join satisfies intersection permission
WHERE t.event_time BETWEEN DATE_SUB(current_date(), 30) AND current_date()
AND t.brand_name = '<collaborator_brand_name>'
GROUP BY t.country
ORDER BY total_revenue DESC
LIMIT 20;
Discover audiences before a user acquisition (UA) campaign
This query uses the All Data permission to segment a collaborator's transactions by country and category, so you can discover high-value audiences before you create one for user acquisition.
SELECT
t.country,
t.category,
COUNT(DISTINCT t.hashed_email) AS total_buyers,
COUNT(*) AS total_purchases,
SUM(t.revenue) AS total_revenue,
AVG(t.revenue) AS avg_order_value
FROM <collaborator_transactions_table> t
WHERE t.event_time BETWEEN DATE_SUB(current_date(), 30) AND current_date()
GROUP BY t.country, t.category
ORDER BY total_buyers DESC
LIMIT 20;
View and download query results
The following sections cover how to run your query and manage its results.
Run modes
Every query runs in one of two modes:
- Sample data (default) runs on a small subset of your data, so you can refine your query before running it on the full dataset.
- All data runs against the complete source. Only this mode has a Download button.
Note
Don't confuse the All data run mode with the All Data permission type described above. Permission types control what a collaborator can access. Run modes control how much of your own query you execute.
Query history
Your query and its results stay in place as you move between tabs and worksheets. You can open multiple worksheets to work on different queries at once.
Select All runs to see your query history, including status and duration for each run, run in either Sample data or All data mode.
Result limits and downloads
Results display in pages of 100 rows, up to 10 pages (1,000 rows total). To see everything, download the results. Your total result count always shows, even if it is larger than what is displayed. This count caps at 10 million, so if your actual result count is 20 million, the displayed count still shows 10 million.
You can download up to 1 million rows directly. If your results are larger, Dynamic Query redirects you to your cloud bucket instead. Your cloud bucket holds up to 10 million rows. If you need more, contact your Customer Success Manager (CSM) to expand this limit.
Traits and limitations
| Trait | Description |
|---|---|
| Result display limit | 1,000 rows (100 rows per page, up to 10 pages) |
| Download limit | 1 million rows direct, 10 million rows through your cloud bucket, contact your CSM to expand |
| Cloud bucket setup | Required before you can run any query, not just before downloading |
| Run modes | Sample data (default, no download) and All data (full source, download available) |