Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(web-analytics): add in-app browser breakdown dimension (#98699)

Lucas Ricoyfbfbdea219f6
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 2be43c6366e0..56ffee10088c 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -56447,6 +56447,7 @@
"FirstPageviewUTMContent",
"FirstPageviewUTMSourceMediumCampaign",
"Browser",
+ "InAppBrowser",
"OS",
"Viewport",
"DeviceType",
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index 6c28a95f5d26..ded27f116ed0 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -3939,6 +3939,7 @@ export enum WebStatsBreakdown {
FirstPageviewUTMContent = 'FirstPageviewUTMContent',
FirstPageviewUTMSourceMediumCampaign = 'FirstPageviewUTMSourceMediumCampaign',
Browser = 'Browser',
+ InAppBrowser = 'InAppBrowser',
OS = 'OS',
Viewport = 'Viewport',
DeviceType = 'DeviceType',
diff --git a/frontend/src/scenes/web-analytics/CrossSellButtons/ReplayButton.tsx b/frontend/src/scenes/web-analytics/CrossSellButtons/ReplayButton.tsx
index b7499709922c..83ea3da1e619 100644
--- a/frontend/src/scenes/web-analytics/CrossSellButtons/ReplayButton.tsx
+++ b/frontend/src/scenes/web-analytics/CrossSellButtons/ReplayButton.tsx
@@ -63,6 +63,7 @@ const BREAKDOWN_TYPE_MAP: Partial<Record<WebStatsBreakdown, PropertyFilterType.E
[WebStatsBreakdown.ExitPage]: PropertyFilterType.Session,
[WebStatsBreakdown.Page]: PropertyFilterType.Event,
[WebStatsBreakdown.Browser]: PropertyFilterType.Event,
+ [WebStatsBreakdown.InAppBrowser]: PropertyFilterType.Event,
[WebStatsBreakdown.OS]: PropertyFilterType.Event,
[WebStatsBreakdown.InitialChannelType]: PropertyFilterType.Session,
[WebStatsBreakdown.InitialReferringDomain]: PropertyFilterType.Session,
@@ -85,6 +86,7 @@ const BREAKDOWN_KEY_MAP: Partial<Record<WebStatsBreakdown, string>> = {
[WebStatsBreakdown.ExitPage]: '$end_pathname',
[WebStatsBreakdown.Page]: '$pathname',
[WebStatsBreakdown.Browser]: '$browser',
+ [WebStatsBreakdown.InAppBrowser]: '$webview_app',
[WebStatsBreakdown.OS]: '$os',
[WebStatsBreakdown.InitialChannelType]: '$channel_type',
[WebStatsBreakdown.InitialReferringDomain]: '$entry_referring_domain',
diff --git a/frontend/src/scenes/web-analytics/common.ts b/frontend/src/scenes/web-analytics/common.ts
index 3f908952fcaf..45085900d47d 100644
--- a/frontend/src/scenes/web-analytics/common.ts
+++ b/frontend/src/scenes/web-analytics/common.ts
@@ -377,6 +377,7 @@ export enum SourceTab {
export enum DeviceTab {
BROWSER = 'BROWSER',
+ IN_APP_BROWSER = 'IN_APP_BROWSER',
OS = 'OS',
DEVICE_TYPE = 'DEVICE_TYPE',
VIEWPORT = 'VIEWPORT',
@@ -430,6 +431,7 @@ export const GEOGRAPHY_DRILL_DOWN_MAP: Partial<Record<WebStatsBreakdown, Geograp
export const DEVICE_DRILL_DOWN_MAP: Partial<Record<WebStatsBreakdown, DeviceTab>> = {
[WebStatsBreakdown.DeviceType]: DeviceTab.BROWSER,
[WebStatsBreakdown.Browser]: DeviceTab.OS,
+ [WebStatsBreakdown.InAppBrowser]: DeviceTab.OS,
[WebStatsBreakdown.OS]: DeviceTab.VIEWPORT,
}
@@ -471,6 +473,8 @@ export const webStatsBreakdownToPropertyName = (
return { key: '$entry_utm_term', type: PropertyFilterType.Session }
case WebStatsBreakdown.Browser:
return { key: '$browser', type: PropertyFilterType.Event }
+ case WebStatsBreakdown.InAppBrowser:
+ return { key: '$webview_app', type: PropertyFilterType.Event }
case WebStatsBreakdown.OS:
return { key: '$os', type: PropertyFilterType.Event }
case WebStatsBreakdown.Viewport:
@@ -653,6 +657,8 @@ export const getDisplayColumnName = (column: string, breakdownBy?: WebStatsBreak
return 'UTM Content'
case WebStatsBreakdown.Browser:
return 'Browser'
+ case WebStatsBreakdown.InAppBrowser:
+ return 'In-app browser'
case WebStatsBreakdown.OS:
return 'OS'
case WebStatsBreakdown.Viewport:
diff --git a/frontend/src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx b/frontend/src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx
index cd5a8959cdba..90706898b4c4 100644
--- a/frontend/src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx
+++ b/frontend/src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx
@@ -376,6 +376,8 @@ const BreakdownValueTitle: QueryContextColumnTitleComponent = (props) => {
return <>UTM Content</>
case WebStatsBreakdown.Browser:
return <>Browser</>
+ case WebStatsBreakdown.InAppBrowser:
+ return <>In-app browser</>
case WebStatsBreakdown.OS:
return <>OS</>
case WebStatsBreakdown.Viewport:
@@ -530,6 +532,11 @@ const BreakdownValueCell: QueryContextColumnComponent = (props) => {
return <PropertyIcon.WithLabel property="$browser" value={value} />
}
return <NotSetBreakdownLabel />
+ case WebStatsBreakdown.InAppBrowser:
+ if (typeof value === 'string') {
+ return <>{value}</>
+ }
+ return <NotSetBreakdownLabel />
case WebStatsBreakdown.OS:
if (typeof value === 'string') {
return <PropertyIcon.WithLabel property="$os" value={value} />
diff --git a/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx b/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
index edbb230dbf32..8b9d3008a117 100644
--- a/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
+++ b/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
@@ -2527,6 +2527,13 @@ export const webAnalyticsLogic: LogicWrapper<webAnalyticsLogicType> = kea<webAna
'Browser',
WebStatsBreakdown.Browser
),
+ createTableTab(
+ TileId.DEVICES,
+ DeviceTab.IN_APP_BROWSER,
+ 'In-app browsers',
+ 'In-app browser',
+ WebStatsBreakdown.InAppBrowser
+ ),
createTableTab(TileId.DEVICES, DeviceTab.OS, 'OS', 'OS', WebStatsBreakdown.OS),
createTableTab(
TileId.DEVICES,
diff --git a/frontend/src/taxonomy/core-filter-definitions-by-group.json b/frontend/src/taxonomy/core-filter-definitions-by-group.json
index e0e24a4a80e6..5b926d8fc7a4 100644
--- a/frontend/src/taxonomy/core-filter-definitions-by-group.json
+++ b/frontend/src/taxonomy/core-filter-definitions-by-group.json
@@ -3625,6 +3625,23 @@
"description": "Whether web vitals was enabled in remote config",
"label": "Web vitals enabled server side"
},
+ "$webview_app": {
+ "description": "Name of the host app whose in-app browser the event came from, such as an event opened inside the LinkedIn or Instagram app. Set from the user agent when the SDK can identify the host app.",
+ "examples": [
+ "LinkedIn",
+ "Instagram",
+ "TikTok"
+ ],
+ "label": "In-app browser"
+ },
+ "$webview_app_version": {
+ "description": "Version of the host app whose in-app browser the event came from.",
+ "examples": [
+ "309.1.0",
+ "375.0.0"
+ ],
+ "label": "In-app browser version"
+ },
"$window_id": {
"description": "Unique window ID for session recording disambiguation",
"label": "Window ID",
@@ -7126,6 +7143,23 @@
"description": "Google Ads, app to web Data from the first time this user was seen.",
"label": "Initial wbraid"
},
+ "$initial_webview_app": {
+ "description": "Name of the host app whose in-app browser the event came from, such as an event opened inside the LinkedIn or Instagram app. Set from the user agent when the SDK can identify the host app. Data from the first time this user was seen.",
+ "examples": [
+ "LinkedIn",
+ "Instagram",
+ "TikTok"
+ ],
+ "label": "Initial in-app browser"
+ },
+ "$initial_webview_app_version": {
+ "description": "Version of the host app whose in-app browser the event came from. Data from the first time this user was seen.",
+ "examples": [
+ "309.1.0",
+ "375.0.0"
+ ],
+ "label": "Initial in-app browser version"
+ },
"$initialization_time": {
"description": "The iso formatted timestamp of SDK initialization.",
"label": "initialization time",
@@ -8783,6 +8817,23 @@
"description": "Whether web vitals was enabled in remote config",
"label": "Web vitals enabled server side"
},
+ "$webview_app": {
+ "description": "Name of the host app whose in-app browser the event came from, such as an event opened inside the LinkedIn or Instagram app. Set from the user agent when the SDK can identify the host app. Data from the last time this user was seen.",
+ "examples": [
+ "LinkedIn",
+ "Instagram",
+ "TikTok"
+ ],
+ "label": "Latest in-app browser"
+ },
+ "$webview_app_version": {
+ "description": "Version of the host app whose in-app browser the event came from. Data from the last time this user was seen.",
+ "examples": [
+ "309.1.0",
+ "375.0.0"
+ ],
+ "label": "Latest in-app browser version"
+ },
"$window_id": {
"description": "Unique window ID for session recording disambiguation",
"label": "Window ID",
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index ae39633b328c..95465184718f 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -3024,6 +3024,7 @@ class WebStatsBreakdown(StrEnum):
FIRST_PAGEVIEW_UTM_CONTENT = "FirstPageviewUTMContent"
FIRST_PAGEVIEW_UTM_SOURCE_MEDIUM_CAMPAIGN = "FirstPageviewUTMSourceMediumCampaign"
BROWSER = "Browser"
+ IN_APP_BROWSER = "InAppBrowser"
OS = "OS"
VIEWPORT = "Viewport"
DEVICE_TYPE = "DeviceType"
diff --git a/posthog/taxonomy/taxonomy.py b/posthog/taxonomy/taxonomy.py
index 398f23581509..085635bb905c 100644
--- a/posthog/taxonomy/taxonomy.py
+++ b/posthog/taxonomy/taxonomy.py
@@ -76,6 +76,8 @@ PERSON_PROPERTIES_ADAPTED_FROM_EVENT: set[str] = {
"$app_version",
"$browser",
"$browser_version",
+ "$webview_app",
+ "$webview_app_version",
"$device_type",
"$current_url",
"$pathname",
@@ -1619,6 +1621,16 @@ CORE_FILTER_DEFINITIONS_BY_GROUP: dict[str, dict[str, CoreFilterDefinition]] = {
"description": "Name of the browser the user has used.",
"examples": ["Chrome", "Firefox"],
},
+ "$webview_app": {
+ "label": "In-app browser",
+ "description": "Name of the host app whose in-app browser the event came from, such as an event opened inside the LinkedIn or Instagram app. Set from the user agent when the SDK can identify the host app.",
+ "examples": ["LinkedIn", "Instagram", "TikTok"],
+ },
+ "$webview_app_version": {
+ "label": "In-app browser version",
+ "description": "Version of the host app whose in-app browser the event came from.",
+ "examples": ["309.1.0", "375.0.0"],
+ },
"$os": {
"label": "OS",
"description": "The operating system of the user.",
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index dde07aadabd9..efba6469719b 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -4472,6 +4472,7 @@ export const WebStatsBreakdownApi = {
FirstPageviewUTMContent: 'FirstPageviewUTMContent',
FirstPageviewUTMSourceMediumCampaign: 'FirstPageviewUTMSourceMediumCampaign',
Browser: 'Browser',
+ InAppBrowser: 'InAppBrowser',
Os: 'OS',
Viewport: 'Viewport',
DeviceType: 'DeviceType',
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index f2ba0f533daf..95051a7c0c36 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -3432,6 +3432,7 @@ export const WebStatsBreakdownApi = {
FirstPageviewUTMContent: 'FirstPageviewUTMContent',
FirstPageviewUTMSourceMediumCampaign: 'FirstPageviewUTMSourceMediumCampaign',
Browser: 'Browser',
+ InAppBrowser: 'InAppBrowser',
Os: 'OS',
Viewport: 'Viewport',
DeviceType: 'DeviceType',
diff --git a/products/web_analytics/backend/hogql_queries/stats_table.py b/products/web_analytics/backend/hogql_queries/stats_table.py
index 5b9a9e08df72..a43b268c7f7c 100644
--- a/products/web_analytics/backend/hogql_queries/stats_table.py
+++ b/products/web_analytics/backend/hogql_queries/stats_table.py
@@ -1002,6 +1002,12 @@ WHERE and(
return first_pageview_filter_value_expr(breakdown, modifiers=self.modifiers, timings=self.timings)
case WebStatsBreakdown.BROWSER:
return ast.Field(chain=["properties", "$browser"])
+ case WebStatsBreakdown.IN_APP_BROWSER:
+ # Non-in-app traffic has no $webview_app, so it drops out via the default
+ # outer_where_breakdown branch (IS NOT NULL). That is intentional: this tile lists
+ # the host apps, not a dominant "(not set)" row for everyone else, so its total does
+ # not reconcile with the overview. Do not add it to the "(not set)" list below.
+ return ast.Field(chain=["properties", "$webview_app"])
case WebStatsBreakdown.OS:
return ast.Field(chain=["properties", "$os"])
case WebStatsBreakdown.VIEWPORT:
diff --git a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_stats_table.ambr b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_stats_table.ambr
index 49724507b10c..6f7f7e7293cf 100644
--- a/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_stats_table.ambr
+++ b/products/web_analytics/backend/hogql_queries/test/__snapshots__/test_web_stats_table.ambr
@@ -3780,6 +3780,49 @@
use_hive_partitioning=0
'''
# ---
+# name: TestWebStatsTableQueryRunner.test_in_app_browser_breakdown_groups_by_webview_app_and_drops_regular_traffic
+ '''
+ SELECT breakdown_value AS `context.columns.breakdown_value`,
+ tuple(uniq(filtered_person_id), NULL) AS `context.columns.visitors`,
+ tuple(sum(filtered_pageview_count), NULL) AS `context.columns.views`,
+ divide(`context.columns.visitors`.1, sum(`context.columns.visitors`.1) OVER ()) AS `context.columns.ui_fill_fraction`
+ FROM
+ (SELECT any(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id)) AS filtered_person_id,
+ count() AS filtered_pageview_count,
+ replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$webview_app'), ''), 'null'), '^"|"$', '') AS breakdown_value,
+ if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), events.`$session_id`, NULL) AS session_id,
+ any(if(ifNull(equals(bitAnd(bitShiftRight(events.`$session_id_uuid`, 76), 15), 7), 0), fromUnixTimestamp(intDiv(accurateCastOrNull(bitShiftRight(events.`$session_id_uuid`, 80), 'Int64'), 1000)), NULL)) AS start_timestamp
+ FROM events
+ LEFT OUTER JOIN
+ (SELECT argMax(person_distinct_id_overrides.person_id, person_distinct_id_overrides.version) AS person_id,
+ person_distinct_id_overrides.distinct_id AS distinct_id
+ FROM person_distinct_id_overrides
+ WHERE equals(person_distinct_id_overrides.team_id, 99999)
+ GROUP BY person_distinct_id_overrides.distinct_id
+ HAVING equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)
+ WHERE and(equals(events.team_id, 99999), and(or(and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-01 00:00:00', 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(toDateTime('2023-12-11 23:59:59', 'UTC')))), 0), or(equals(events.event, '$pageview'), equals(events.event, '$screen')), 1))
+ GROUP BY session_id,
+ breakdown_value)
+ GROUP BY `context.columns.breakdown_value`
+ HAVING isNotNull(`context.columns.breakdown_value`)
+ ORDER BY `context.columns.visitors` DESC,
+ `context.columns.views` DESC,
+ `context.columns.breakdown_value` ASC
+ LIMIT 101
+ OFFSET 0 SETTINGS readonly=2,
+ max_execution_time=60,
+ allow_experimental_object_type=1,
+ max_ast_elements=4000000,
+ max_expanded_ast_elements=4000000,
+ max_bytes_before_external_group_by=0,
+ transform_null_in=1,
+ optimize_min_equality_disjunction_chain_length=4294967295,
+ optimize_rewrite_aggregate_function_with_if=0,
+ optimize_min_inequality_conjunction_chain_length=4294967295,
+ allow_experimental_join_condition=1,
+ use_hive_partitioning=0
+ '''
+# ---
# name: TestWebStatsTableQueryRunner.test_include_host_concatenates_host_and_path_0_Page
'''
SELECT toTimeZone(events.timestamp, 'UTC') AS timestamp
diff --git a/products/web_analytics/backend/hogql_queries/test/test_web_stats_table.py b/products/web_analytics/backend/hogql_queries/test/test_web_stats_table.py
index 4e8fb5f84c26..bdd8b126aed7 100644
--- a/products/web_analytics/backend/hogql_queries/test/test_web_stats_table.py
+++ b/products/web_analytics/backend/hogql_queries/test/test_web_stats_table.py
@@ -317,6 +317,30 @@ class TestWebStatsTableQueryRunner(
["Login", (1, None), (1, None), 1 / 3, ""],
] == results
+ def test_in_app_browser_breakdown_groups_by_webview_app_and_drops_regular_traffic(self):
+ s1 = str(uuid7("2023-12-02"))
+ s2 = str(uuid7("2023-12-03"))
+ s3 = str(uuid7("2023-12-04"))
+ s4 = str(uuid7("2023-12-05"))
+ # The regular-browser pageview has no $webview_app and must be dropped, not shown as a
+ # "(not set)" row: the in-app browser tile answers "which host apps", not "how much
+ # traffic is not in-app".
+ self._create_events(
+ [
+ ("li1", [("2023-12-02", s1, "/", {"$webview_app": "LinkedIn"})]),
+ ("li2", [("2023-12-03", s2, "/", {"$webview_app": "LinkedIn"})]),
+ ("ig1", [("2023-12-04", s3, "/", {"$webview_app": "Instagram"})]),
+ ("web1", [("2023-12-05", s4, "/")]),
+ ]
+ )
+
+ results = self._run_web_stats_table_query(
+ "2023-12-01", "2023-12-11", breakdown_by=WebStatsBreakdown.IN_APP_BROWSER
+ ).results
+
+ assert [row[0] for row in results] == ["LinkedIn", "Instagram"]
+ assert all(row[0] not in (None, "") for row in results)
+
def test_all_time(self):
s1a = str(uuid7("2023-12-02"))
s1b = str(uuid7("2023-12-13"))
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 0395967d8b48..ef9d19b8f3e7 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -5156,6 +5156,7 @@ export namespace Schemas {
FirstPageviewUTMContent: 'FirstPageviewUTMContent',
FirstPageviewUTMSourceMediumCampaign: 'FirstPageviewUTMSourceMediumCampaign',
Browser: 'Browser',
+ InAppBrowser: 'InAppBrowser',
Os: 'OS',
Viewport: 'Viewport',
DeviceType: 'DeviceType',
diff --git a/services/mcp/src/tools/generated/web_analytics.ts b/services/mcp/src/tools/generated/web_analytics.ts
index 776fcdfb5e7f..e97d9c772921 100644
--- a/services/mcp/src/tools/generated/web_analytics.ts
+++ b/services/mcp/src/tools/generated/web_analytics.ts
@@ -572,6 +572,7 @@ const WebStatsBreakdown = z.enum([
'FirstPageviewUTMContent',
'FirstPageviewUTMSourceMediumCampaign',
'Browser',
+ 'InAppBrowser',
'OS',
'Viewport',
'DeviceType',
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-web-stats.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-web-stats.json
index 5996c61e19ff..608a3c91587d 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-web-stats.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-web-stats.json
@@ -28,6 +28,7 @@
"FirstPageviewUTMContent",
"FirstPageviewUTMSourceMediumCampaign",
"Browser",
+ "InAppBrowser",
"OS",
"Viewport",
"DeviceType",