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(marketing): show ad placement in search position cells (#113687)

Javier Bahamondesa3b2a384eee1
diff --git a/docs/internal/marketing-source-suggestions.md b/docs/internal/marketing-source-suggestions.md
index 5c647f4feefb..f67d948625f3 100644
--- a/docs/internal/marketing-source-suggestions.md
+++ b/docs/internal/marketing-source-suggestions.md
@@ -15,6 +15,15 @@ These counts guide connection suggestions; they do not change report attribution
Spend and conversions require a synced ad platform source in the current search filters.
Google Search Console reports organic traffic metrics only.
+The Traffic view always includes the Position column when Google Search Console, Google Ads, or Bing Ads is ready.
+The Position cell shows the organic average position for Google Search Console, or top and first-position impression percentages for Google Ads or Bing Ads.
+Hover over each label or value, or focus it with the keyboard, for its definition.
+Google Ads percentages use Google Search impressions with placement data, weighted by impressions; Search partners are excluded.
+Bing Ads percentages use Microsoft Advertising report values, weighted by impressions.
+They do not identify second or third position, or the search results page.
+Existing Google Ads connections need to sync `keyword_stats` or `landing_page_stats` to import the new fields.
+Bing Ads connections need to sync `keyword_performance_report` or `destination_url_performance_report`.
+Older rows without placement data show no value.
When no paid source is ready, the disabled control directs users to check their source settings or filters.
For Google Ads landing pages, enable `landing_page_stats` and wait for its first sync to finish.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index ef35544f82d1..c04bf12a910a 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -12123,81 +12123,89 @@ snapshots:
scenes-app-marketing-analytics-search-performance--awaiting-sync--light:
hash: v1.k794b7964.1e682849cf3ff944c156abae9e4a762cbfb4a6067a3a28b92f0a900f62d781cd.2NWULrKTIdOxwZwMcOOWiXaakv5AQ5GNtbiACz2FzyU
scenes-app-marketing-analytics-search-performance--comparison--dark:
- hash: v1.k794b7964.da4a489bbd60a01ac3278d616783a98563d38e3430ff96427a0e1057cd417393.VLQXGho9dJX3L0DgD12LtAhADq6a2m-xzF4DK02BjZg
+ hash: v1.k794b7964.294560effba5b80ee5d4d15cb1831e13b8653cf66460d49b115fc8ffa0509469.CeJxXMixs1ZBQLtS6_iMOUzqt7mk88VlfQyYNg4ycgw
scenes-app-marketing-analytics-search-performance--comparison--light:
- hash: v1.k794b7964.bcfe64356d716b21113f8814f0ec8b9cf32dcab36c1b837873f782764e0f3650.JJA1JqMHNbu5xeMZ867GXPIrPPFmWED402YuC-wPnsc
+ hash: v1.k794b7964.8c43dcef5374e8b86c424cdcac6f2f4c17f99c625d0f86d4c29b388b8d8b94c7.lLEjjoOVQ1EPRdpjDlLZo8dwuG4Fbjj8KolANPkLqak
scenes-app-marketing-analytics-search-performance--connected--dark:
- hash: v1.k794b7964.fed77229a94d34e7b474d6e196843ef43dede3929bb999a38ac629529f612d89.nf0LcTGUhk75Lw9Bxf6WI0SRRlf_zN278kCKWKRW-1Q
+ hash: v1.k794b7964.bb8c5f0f95ed928afdfe369684ec8ea79e833c4d7a76982ca90a30029ab15553.tpxMP9GQUCgjShf-AM5vpKMhy-xlDPMOgBL7TAofaAs
scenes-app-marketing-analytics-search-performance--connected--light:
- hash: v1.k794b7964.685d98322b8bf4940eb384317b070ae7026e82be665b3848ed6bdcd3d59224e9.UExTHm9fzNvTY9g9t31gWz3TBGacLRm2kj_OhbRiamQ
+ hash: v1.k794b7964.7c65a5117b8af03b312f6c708b3c24d88c64fff18781a7963dd748b4fb213739.tb-Wg9Bl1iwA9nzDfGckVUZ6VkWOaSRPXkuLSqLCu3s
scenes-app-marketing-analytics-search-performance--empty--dark:
- hash: v1.k794b7964.7361623ddfa744d10e1f69d91ed046cfed96397bed5900c9b5040838e03c8421.BqO8M90qUA2SQEH01p7koER1Lf1gC_COTYB1e4cAbxI
+ hash: v1.k794b7964.3ec92d393624d81f6a15d219e49673ec132a9a2ed6d1b6894316341ddd802551.8XnU6e5oAZzx6GSZlSWCxIiLkUKGlXv-wPhD24UkXnI
scenes-app-marketing-analytics-search-performance--empty--light:
- hash: v1.k794b7964.3c644577458d384fdbf2b4283a1b008b11bdcda089a9564c50ef6fb5aea32e65.fmuaZYzsXZBv8WcNrPIyLjH1iEPG0yy_iWghDF6reWQ
+ hash: v1.k794b7964.186c76ee436d57a2ace32c24d69f8d701da6ba0cc5dc0f2e05f69adf5e87becc.tXoDCBlh6OEYxCMqIMNb2aK1WvQoDmy9i2Ibc8r5ePk
scenes-app-marketing-analytics-search-performance--empty-google-ads--dark:
- hash: v1.k794b7964.0f6481d56f5c834dc8f2ef6b44da971336ff939111e0321062352deea3fb0fd4.SJ6RAScjMk_PlLOSqw1FIvRTsBCEPWwCXkFeUlNuCDg
+ hash: v1.k794b7964.aa6a8f5a0b21b7da560d23b891b3fefe3b9a45b01a608b587c533d4d9e8c1683.0p1g-uP8uzVjr9CvNND07WrFS_kzY454QecIq-y_YI8
scenes-app-marketing-analytics-search-performance--empty-google-ads--light:
- hash: v1.k794b7964.6c210113b336340aa2d909ad0476433fd34955ca9eb162abdd98be5e5d1f83b6.QBHwog3p1CZJG9k5hq7HryES4_XydV0ZN18xsqC5qhU
+ hash: v1.k794b7964.9cdce338e8e20de934631c077b4d1f9d4d9e172950d0e3d1f69466ccde642814.vyj7x558WrjvOIT0L1xQVN6Z6ThPtI66zBGfQqPS-JU
scenes-app-marketing-analytics-search-performance--empty-organic--dark:
hash: v1.k794b7964.d8b9d9dc91ad11c6140e5d1f8abeafae5fcd3c04cdf540a5c68bee4f3eb91efd.qQPQzDTrd47vIOq0wlEp3-y-xHfNhKhpOQI38UN5k-M
scenes-app-marketing-analytics-search-performance--empty-organic--light:
hash: v1.k794b7964.c5637a6fd1601c5e0898097d5737198f0732b5ec61678bc7494c8d873edcd205.YwB0Plncvous1yGLtPdic3wjrjIyzppw4tUWSNS3a4o
scenes-app-marketing-analytics-search-performance--filtered-empty--dark:
- hash: v1.k794b7964.6d4eaab46788b1f1e2e9a093a93343a26fd019c3faadc7cc9d48b012b015949d.pO4k8JGzVkm9AwIqKs2m881lL5-UJgPlMEleFZ-rOt4
+ hash: v1.k794b7964.134923295dd414ef27c3f207abc72cde891f4e8003388becf3cccc06291f5135.sJ4xYmcwjasPGUUJVC-gFlCoAG-LPgovBDejH3fLySY
scenes-app-marketing-analytics-search-performance--filtered-empty--light:
- hash: v1.k794b7964.7a749b50debb64abf43def8dd705bbc026e5ab0b5b1ca13e6728efb6bdfca1d1.0nGet0e8mq_5ok7RXQREG3gkeBUADKYVrnZJ7o7j9yQ
+ hash: v1.k794b7964.a1c00f73f851570346fc953635757b8d9e1c6d7a86ad825fff29178fb27853e3.AxEE4yJorUfN_KWVgT_7hZi57fpzKudX9T-DdaCrk1c
scenes-app-marketing-analytics-search-performance--flag-off--dark:
hash: v1.k794b7964.0abe2d58ee70ac24582205caacee0e0b09831b9f04687d5ee1d9ec28f7f99be8.23pCSt9pA4N6R0id0jXh6Z0GpGSmmifTz1Ur090dRnY
scenes-app-marketing-analytics-search-performance--flag-off--light:
hash: v1.k794b7964.9336af8fdbf0c10e0dadbdc398517b3856ad19eae7ff0f580ddd507e4202b57b.92lmvS4XqmLPpRq2h7e7R_7p8x2ZpdvIaIAKZRL4lQU
scenes-app-marketing-analytics-search-performance--landing-pages--dark:
- hash: v1.k794b7964.289770d75deebad839afe43097292762614598ad52551dd619598f2706773f45.ChEsO2JPUZS_jiF3HcQZyICjrL8KLQM_QBKHj0pdytk
+ hash: v1.k794b7964.29b053772e999bc3a7b7a15af10edbe8e66b4058480765211c5d32bf8a59455b.4b6Gq4jtag02HdrpJLUyDwNsCswDOKjlKF22L0tY1PM
scenes-app-marketing-analytics-search-performance--landing-pages--light:
- hash: v1.k794b7964.01c9c7484939a58b55a3664f2ed87f903f5e5dd5636c31918b6efe31253642b5.3dfRb_8K5xRRGzR2uHJ5jUWCYaVOmxVVUs9LKAiujyg
+ hash: v1.k794b7964.46f8f023b9421f130ef44fb3c8d67efde0078e4ca64c284a9fe4c26d09a84b2f.bkrzKqnWPsYtAImvYCF_27fS96W8H0I2X5SpP0cufsU
scenes-app-marketing-analytics-search-performance--legacy-scene--dark:
- hash: v1.k794b7964.79803ad82b7c9d0112e8915230cc17bb0fb627f450f8b3212dfa5398d079465d.dM0uXKDYjEZqKXq4eZ7QcLK2wP3NAYjmmkl45CU0G7Q
+ hash: v1.k794b7964.528f8619e82f505300da3cdde492e8449e96fe8ca6bf30989bef53e09b05c7eb.iu6npa-sDBvCBH9BBtv2rfxt5_3j94kn-tZL9K-SZqo
scenes-app-marketing-analytics-search-performance--legacy-scene--light:
- hash: v1.k794b7964.15c6cfa3a0f734a07073c4cbff5997267408a1a2d74ec9f7f3bea24cec3957ad.CZzg97JJMY24EiK5gti3sWvzSK_t2jNaiO5M5dJEPF8
+ hash: v1.k794b7964.49ac347634c98eb6f02a56fcf7460f06623e536f1050d653eaff86c4892bc3e1.bxhBI3hLqSpebwoao3zjXOXlZu2dzSfHGpde4HjX2sw
scenes-app-marketing-analytics-search-performance--loading--dark:
- hash: v1.k794b7964.e8b3da971882e1673916af543e9f93576a35214e978f5351506fab59d673003e.LN9Bi8RdQqlOoo4DBKqtjgOEgVlVIjL2BE6K5AZGLH0
+ hash: v1.k794b7964.de27573aa11ac398c16f34a20ad71335dcf5c7e971e3dfacb29bf96172cfbfb6.kjj15JEZGEGna4XwSxsAJxC3dk6x7gxpMh8GOnI6BfA
scenes-app-marketing-analytics-search-performance--loading--light:
- hash: v1.k794b7964.9bcc8a3217b226695e87b8246bf586da01f455a1149ee158e34dfbcc64306cb5.Nriy1X-7lsMBQR4lMZfCWHuj1m1SMAndmYBOdSaYiZc
+ hash: v1.k794b7964.1aabfe92d510fe185c33f365df060c474e68924266b734a2ab5a9d89e4c9340d.3bRhuyXO1ni554CW3Gbc_RI0aeaQooj8fsv_A0XsxMM
scenes-app-marketing-analytics-search-performance--mixed-with-position--dark:
- hash: v1.k794b7964.ef717d85440987bfbc784867e3ba4b2c491970fa77550b3ab942fb4975dcf866.LQyQ5KtbFtklDsJ8gE93mdQ0yRip2buA4XZNkHNAgDo
+ hash: v1.k794b7964.7e311bce137022a4855d89712362463f9ce7e349680f5fc8f89bf169e5859c91.gRS2pasfn2rj9GCUmYnNuZyZ3cIgwNhyQ1YlWXEXKFA
scenes-app-marketing-analytics-search-performance--mixed-with-position--light:
- hash: v1.k794b7964.8889fadec986fe25371f5bd0dc2050cd842f1e36a83553c41c4e711280c3edce.FaPb9-ILhVXPSALNNIMhLbYIeeHgzD89eDF2976cj44
+ hash: v1.k794b7964.10ed7569a28fa89123c30f6bbf0f82eaeb9978a9f06df752408eaedba2b91b99.vkbFkh267ljd8X1fpbe_pBNFyGDRzR5UDisgtyooKrw
scenes-app-marketing-analytics-search-performance--narrow--dark:
- hash: v1.k794b7964.bde1f1e8363ddf5f995c027fc7bb573f980e19dc392013968b65a002a933cfca.eJhwMI5ucoT8b5Jea3q3aMsKpiFUmp8dZZEU_MxjjrQ
+ hash: v1.k794b7964.7ff78e79759406b341fa14f02323a419f2459fca95559ee28e33670f77477760.ovx1lAqDcEiGNxlM59g-kRafOMQf7VckY386T9RF0zs
scenes-app-marketing-analytics-search-performance--narrow--light:
- hash: v1.k794b7964.85156ee128bad45622b2629a8b060d5dca86beea088a63a3ba04e1542c9aca79.Z0_KMaRMswpz6kiy3pLenU2tGdkX0DujGrB2h_nHbDo
+ hash: v1.k794b7964.bfd5d31c098a109b317812dff57c6767adf6355d5ae406e9ce7bd6b56e935243.fvsoF--EG453u5aYdDvZC-53ih4ATaSTk_8s-mD_uuE
+ scenes-app-marketing-analytics-search-performance--narrow-position-metrics--dark:
+ hash: v1.k794b7964.266dd131353e18eed7fdd28594ade506066e4efbc2e0e11d98717157c1caf4f9.P82zB4WPxONi1U5nBZnthihcY5f-U7sH7EO6Sezazl4
+ scenes-app-marketing-analytics-search-performance--narrow-position-metrics--light:
+ hash: v1.k794b7964.f8c8d0769d6755ab36b068c802007afc514e52c0c758c857d1f68716a709001b.Uk_7wLybbodycRRq4CGCya1G_6wfGifJOO5daIyXOmw
scenes-app-marketing-analytics-search-performance--new-dashboard-flag-off--dark:
hash: v1.k794b7964.7adfc0ee89093703b8e923935870475615161314419fa409f03a59f9de5ec90b.6AeZyZLr78BXMkf-QvQSLQv7xF5-EpIyAwQSVD55YG4
scenes-app-marketing-analytics-search-performance--new-dashboard-flag-off--light:
hash: v1.k794b7964.2502d21dc38a51fef502b7ef452df680896462b29284847d1d107a7c0daf8727.nDQD9ooWp2VeSndPJnTKI4DVAZY5WNbdi41Y_vSBqYM
scenes-app-marketing-analytics-search-performance--new-dashboard-scene--dark:
- hash: v1.k794b7964.fc711c95950ca75ea72227bf5e456cddc49d332363f865c79de97180678ebc8f.CmUxds9gU22ruBIr7yDyZF0HLfDM3SgwyDGnEtevcsw
+ hash: v1.k794b7964.c9d2a5e642c4ea71466e2362921716dbbe907528e6945087457acb4de67f0b1c.Gb69-O2UY44IrGFprwj7DwI781F2jRorAa9CIcUDz20
scenes-app-marketing-analytics-search-performance--new-dashboard-scene--light:
- hash: v1.k794b7964.86b09107dfff85bc5f3bfc9f02cf1f2768cfe9520fe264c4f32e29a841d9640f.rFANw9dORBZxXQr4akkqk0kRIJCWQe_Em3ffDtw22ac
+ hash: v1.k794b7964.7040d5f41b1f894b6f2a08b234cdc2c149fb4853781449980e11be2720225605.JAx-htAe1_EswWOTb4kDbLfszwryJdmXabqKf4gn2n4
scenes-app-marketing-analytics-search-performance--not-connected--dark:
hash: v1.k794b7964.fc45f91fd10720c94e64d84bd64d043e472d35c7be2a2c813f98a627fbbd93be.OvmqVf3mYSyJ_wXsOKvp-LWwhymTTD6MbSikTmLg564
scenes-app-marketing-analytics-search-performance--not-connected--light:
hash: v1.k794b7964.d26e073f6322a6a5408b4b612361749f47d3b4cba38a82caf6210215db7b339a.c0EL08UuZQQZ3H5Euck3vSNLJSImyrOkGtYHoZOLzH4
scenes-app-marketing-analytics-search-performance--only-google-ads--dark:
- hash: v1.k794b7964.dbc748f51f11da69156a9d152c1b87f2cbc8d34e17777bcef40df89bb9e3f579.TQGapnKNvsxpS6Q9G4KQ83kG3RsrqCEvpefof05-G8g
+ hash: v1.k794b7964.a8a745456b230bef0f24c83ebbe4b4729b20e05f314b24f6b9286624a66b1e8e.-PIn5NrwInd10AEjCmGbAxQooGdg9GQsi24w8tVQqxE
scenes-app-marketing-analytics-search-performance--only-google-ads--light:
- hash: v1.k794b7964.8af18d07a7e2bd7e3328bd71225fb3f2ed7e76e3a748b51610d08f4ef31e5eb6.rLarOIv0GghPfWGPJs19PdgfziIgLTodLQDszMgPIkg
+ hash: v1.k794b7964.a730e9b72953c9491973057a1569a43a77afb69c112f6d97b3a3557817f7106a.jCP4HaeNUfbs94tZVoHRQsNskhCIw5LEPo_-usWWIyk
scenes-app-marketing-analytics-search-performance--organic-detail--dark:
- hash: v1.k794b7964.590ef075a7d1ce48e0d9dfd82e32c27f11f27a932b582ebd9b5f84e61c4b23e7.OJbK-8ImktYE25NEH7-dwU1yqCzcSKTgJ3DaM5v_nHI
+ hash: v1.k794b7964.eecc1e0d6ab7016af9e7a8813a6a397e1abed44c2b01c818faeb93381b38d6a7.6HlDIZm2i8NxcgWoChbdUtm15NO4kfUY1nZDd60CAnU
scenes-app-marketing-analytics-search-performance--organic-detail--light:
- hash: v1.k794b7964.a5478e8d78aa10ec347237992737fbd38942d2d65cc0914243bc130aca52dfcb.Z7H4tw2dzbkAkNTAz8kQYTZBcI-4Yvy4RxcZaPZTm0Y
+ hash: v1.k794b7964.4655a0c3a68fd813630b86fb1a705ad3a9961ad09df27d5ce75b3e5ab0bf3cec.QBK2ZQldJDfLR70254la5sF8RNIooYgFjC7R8jE0If8
scenes-app-marketing-analytics-search-performance--organic-traffic--dark:
hash: v1.k794b7964.7ba41e4f8a805ede72988abf68da5ca71fdd5ea49e54ae1a1429395b0d5395c8.spzxSw17uk9MAi9eoFImUrzH8Anni36d5WJz6RkVNZ4
scenes-app-marketing-analytics-search-performance--organic-traffic--light:
hash: v1.k794b7964.b489f95489321db0b4880bab8e0c7d6660751c66b6ad97a22e412a8aefb61f81.2jCSJbAJrEZ2T1LLtgwtgcp_f6pvcKzSxBidM7FPYnE
scenes-app-marketing-analytics-search-performance--pagination--dark:
- hash: v1.k794b7964.e9e58780ceb0c43662f398a8c9f3f384594019c76ed30cff1455b38e9f829c4c.Q2-h9ci1VnBriXD9zUqh7p8YlVxgpapD8S2rJPqNwrY
+ hash: v1.k794b7964.335e317721a8c9048bb23873444f0e217a3a1c16c7f5df90a6e7e9b56eccc17e.MTtJBu_VnIKhamkJogojTo0n82UPnRL2ooBj1pmu9g4
scenes-app-marketing-analytics-search-performance--pagination--light:
- hash: v1.k794b7964.cf0100b7d5f64a9025ec09043be81637b4c6dfe20119fdce9c78bcb559d3c055.E1u-Ch73ICFOr1Hxy-jpjKL6jeT8KMtshGU_NI2jmk0
+ hash: v1.k794b7964.0aadfd41174c836d09256ecb4b2b2b14262da464c649ad906911d014f4756f69.aJLdwc-ThHLyjpXcx_LBTqvitPN4bYvRNZ8Hv91zBsQ
+ scenes-app-marketing-analytics-search-performance--position-metrics--dark:
+ hash: v1.k794b7964.3757126e384ddc22242bce51a71f1f2556530e576885ca5cbd315163d73a3465.GTDt8Kt1dD6av9gY0MiCCLOZU7eeqEpYLwNjzfFYXBY
+ scenes-app-marketing-analytics-search-performance--position-metrics--light:
+ hash: v1.k794b7964.9de59f956ed52561dc4f5c686b1181cf27b05fa2716e7fba7e72478150c9289a.mkWxcDY4QLtr0t57sTgwgvPrXOPJ2EspMJTid1urRng
scenes-app-marketing-analytics-search-performance--query-error--dark:
hash: v1.k794b7964.a5419c8a09ca30185fc876c1631efb87ce8d017398ebcced2fa8d652e21f2384.GT50JRsrPVWV-OG5VIDpTgX8_wzYvIMrjseLhp24jxY
scenes-app-marketing-analytics-search-performance--query-error--light:
@@ -12207,9 +12215,9 @@ snapshots:
scenes-app-marketing-analytics-search-performance--sources-error--light:
hash: v1.k794b7964.159cf8b9647d98ad2c63ce40109229e9ffd0352de1d98167b9446794a947ff21.gupk_qTVysxLVkierQb3CrLvQ4-AtOFEXoQ4yuxHtlU
scenes-app-marketing-analytics-search-performance--stale-aggregate--dark:
- hash: v1.k794b7964.226342e45a774583025c9988c51e0b775fa69aa4035467373e672c3265f9d895.p0Bym6Yw58dJHLXxXSZMVOcDkTFQ3KYxEwnBTIN6Nkk
+ hash: v1.k794b7964.a1dc072839611ba87b322b279f8542494e79befbdc47412d4bfa2c8e2c1cfde6.6za9eDfEOscGuhgQ1H43qyZxihj-zRPmHCsvNlyEiTA
scenes-app-marketing-analytics-search-performance--stale-aggregate--light:
- hash: v1.k794b7964.83f38c49b6c2036cca2f9307418d58a0dd9e3b7063bde6fc6aa38b3bc5d58704.X9WJX0-nqOFB39GZu5dJNnpecnjb9gwyPVlCeKI8oVw
+ hash: v1.k794b7964.84ae8ac75d3ba6b5dca4d60369bdc43618e45a4357a11aa94ce160d45eeb9773.w5PejTUWCbtvypV3b6TN2FjEiX2rlMG8wWrs9x3WH7g
scenes-app-marketing-analytics-search-performance--unavailable-sources--dark:
hash: v1.k794b7964.f6115da5bb35e65e9e48dda2f2caa8c3ea2c5d29b2e820f0a151f544f9d9c6c6.JiUwR7QskSO2lnI3Iq0P_NclgAPQye-fndfCTAjqDsQ
scenes-app-marketing-analytics-search-performance--unavailable-sources--light:
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 684cadcd3042..b86c78f8ff8f 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -36467,6 +36467,10 @@
"MarketingAnalyticsSearchMetrics": {
"additionalProperties": false,
"properties": {
+ "absoluteTopImpressionRate": {
+ "description": "Fraction of Google Search ad impressions shown as the first ad.",
+ "type": ["number", "null"]
+ },
"clicks": {
"type": "number"
},
@@ -36490,6 +36494,10 @@
},
"position": {
"type": ["number", "null"]
+ },
+ "topImpressionRate": {
+ "description": "Fraction of Google Search ad impressions shown among the top ads.",
+ "type": ["number", "null"]
}
},
"required": ["clicks", "impressions", "cost", "conversions", "ctr", "cpc", "cpa"],
@@ -36613,6 +36621,10 @@
"MarketingAnalyticsSearchRow": {
"additionalProperties": false,
"properties": {
+ "absoluteTopImpressionRate": {
+ "description": "Fraction of Google Search ad impressions shown as the first ad.",
+ "type": ["number", "null"]
+ },
"clicks": {
"type": "number"
},
@@ -36662,6 +36674,10 @@
"type": "null"
}
]
+ },
+ "topImpressionRate": {
+ "description": "Fraction of Google Search ad impressions shown among the top ads.",
+ "type": ["number", "null"]
}
},
"required": [
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index 93ecf31c5e73..ee04527219e9 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -8238,6 +8238,10 @@ export interface MarketingAnalyticsSearchMetrics {
cpc: number | null
cpa: number | null
position?: number | null
+ /** Fraction of Google Search ad impressions shown among the top ads. */
+ topImpressionRate?: number | null
+ /** Fraction of Google Search ad impressions shown as the first ad. */
+ absoluteTopImpressionRate?: number | null
}
export interface MarketingAnalyticsSearchRow extends MarketingAnalyticsSearchMetrics {
diff --git a/posthog/schema.py b/posthog/schema.py
index ceacbcadb9c8..53dfb52b758e 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -2084,6 +2084,10 @@ class MarketingAnalyticsSearchMetrics(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
+ absoluteTopImpressionRate: float | None = Field(
+ default=None,
+ description="Fraction of Google Search ad impressions shown as the first ad.",
+ )
clicks: float
conversions: float | None = None
cost: float | None = None
@@ -2092,12 +2096,20 @@ class MarketingAnalyticsSearchMetrics(BaseModel):
ctr: float | None = None
impressions: float
position: float | None = None
+ topImpressionRate: float | None = Field(
+ default=None,
+ description="Fraction of Google Search ad impressions shown among the top ads.",
+ )
class MarketingAnalyticsSearchRow(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
+ absoluteTopImpressionRate: float | None = Field(
+ default=None,
+ description="Fraction of Google Search ad impressions shown as the first ad.",
+ )
clicks: float
conversions: float | None = None
cost: float | None = None
@@ -2112,6 +2124,10 @@ class MarketingAnalyticsSearchRow(BaseModel):
platform: Platform
position: float | None = None
previous: MarketingAnalyticsSearchMetrics | None = None
+ topImpressionRate: float | None = Field(
+ default=None,
+ description="Fraction of Google Search ad impressions shown among the top ads.",
+ )
class MarketingAnalyticsSearchSource(BaseModel):
diff --git a/products/marketing_analytics/backend/hogql_queries/marketing_search_query_runner.py b/products/marketing_analytics/backend/hogql_queries/marketing_search_query_runner.py
index b4560c3f39b3..f5e6cf241efa 100644
--- a/products/marketing_analytics/backend/hogql_queries/marketing_search_query_runner.py
+++ b/products/marketing_analytics/backend/hogql_queries/marketing_search_query_runner.py
@@ -11,8 +11,10 @@ from posthog.schema import (
)
from posthog.hogql import ast
+from posthog.hogql.context import HogQLContext
+from posthog.hogql.database.database import Database
from posthog.hogql.parser import parse_expr, parse_select
-from posthog.hogql.query import execute_hogql_query
+from posthog.hogql.query import create_default_modifiers_for_team, execute_hogql_query
from posthog.hogql_queries.query_runner import AnalyticsQueryRunner
from posthog.hogql_queries.utils.query_compare_to_date_range import QueryCompareToDateRange
@@ -52,6 +54,47 @@ class MarketingAnalyticsSearchQueryRunner(AnalyticsQueryRunner[MarketingAnalytic
now=self.now,
)
+ @cached_property
+ def hogql_database(self) -> Database:
+ return Database.create_for(
+ team=self.team,
+ user=self.user,
+ modifiers=create_default_modifiers_for_team(self.team, self.modifiers),
+ timings=self.timings,
+ )
+
+ @cached_property
+ def hogql_context(self) -> HogQLContext:
+ modifiers = create_default_modifiers_for_team(self.team, self.modifiers)
+ return HogQLContext(
+ team_id=self.team.pk,
+ modifiers=modifiers,
+ database=self.hogql_database,
+ )
+
+ def _placement_fields(self, source: MarketingAnalyticsSearchSource) -> dict[str, ast.Expr]:
+ table = self.hogql_database.get_table(source.statsTable.split("."))
+ fields = (
+ (
+ ("top_rate", "metrics_top_impression_percentage"),
+ ("absolute_top_rate", "metrics_absolute_top_impression_percentage"),
+ )
+ if source.sourceType == "GoogleAds"
+ else (
+ ("top_rate", "top_impression_rate_percent"),
+ ("absolute_top_rate", "absolute_top_impression_rate_percent"),
+ )
+ )
+ result: dict[str, ast.Expr] = {}
+ for name, field in fields:
+ value: ast.Expr = ast.Field(chain=["s", field]) if table.has_field(field) else ast.Constant(value=None)
+ result[name] = (
+ parse_expr("toFloatOrNull(replaceAll(toString({value}), '%', '')) / 100", placeholders={"value": value})
+ if source.sourceType == "BingAds" and table.has_field(field)
+ else value
+ )
+ return result
+
def _source_query(
self, source: MarketingAnalyticsSearchSource, date_range: QueryDateRange, period: int
) -> ast.SelectQuery | ast.SelectSetQuery:
@@ -61,6 +104,8 @@ class MarketingAnalyticsSearchQueryRunner(AnalyticsQueryRunner[MarketingAnalytic
"date_from": ast.Constant(value=date_range.date_from()),
"date_to": ast.Constant(value=date_range.date_to()),
}
+ if source.sourceType in ("GoogleAds", "BingAds"):
+ placeholders.update(self._placement_fields(source))
if source.sourceType == "GoogleSearchConsole":
if (self.query.keyword is not None or self.query.page is not None) and not source.queryPageTable:
raise ValueError("Search details require the query and page table")
@@ -91,7 +136,9 @@ class MarketingAnalyticsSearchQueryRunner(AnalyticsQueryRunner[MarketingAnalytic
'GoogleSearchConsole' AS platform, NULL AS matchType, NULL AS currency,
sum(toFloat(clicks)) AS click_count, sum(toFloat(impressions)) AS impression_count,
0 AS total_cost, 0 AS conversion_count,
- sum(toFloat(s.position) * toFloat(s.impressions)) AS position_total
+ sum(toFloat(s.position) * toFloat(s.impressions)) AS position_total,
+ NULL AS top_impressions, 0 AS top_eligible_impressions,
+ NULL AS absolute_top_impressions, 0 AS absolute_top_eligible_impressions
FROM {stats} AS s
WHERE toDate(date) >= toDate({date_from}) AND toDate(date) <= toDate({date_to})
AND {keyword_filter} AND {page_filter}
@@ -107,8 +154,12 @@ class MarketingAnalyticsSearchQueryRunner(AnalyticsQueryRunner[MarketingAnalytic
nullIf(upper(currency_code), '') AS currency,
sum(toFloat(clicks)) AS click_count, sum(toFloat(impressions)) AS impression_count,
sum(toFloat(spend)) AS total_cost,
- sum(toFloat(conversions_qualified)) AS conversion_count, 0 AS position_total
- FROM {stats}
+ sum(toFloat(conversions_qualified)) AS conversion_count, 0 AS position_total,
+ sum({top_rate} * toFloat(s.impressions)) AS top_impressions,
+ sumIf(toFloat(s.impressions), {top_rate} IS NOT NULL) AS top_eligible_impressions,
+ sum({absolute_top_rate} * toFloat(s.impressions)) AS absolute_top_impressions,
+ sumIf(toFloat(s.impressions), {absolute_top_rate} IS NOT NULL) AS absolute_top_eligible_impressions
+ FROM {stats} AS s
WHERE toDate(time_period) >= toDate({date_from}) AND toDate(time_period) <= toDate({date_to})
AND ad_distribution = 'Search'
GROUP BY page, currency
@@ -127,8 +178,12 @@ class MarketingAnalyticsSearchQueryRunner(AnalyticsQueryRunner[MarketingAnalytic
sum(toFloat(metrics_clicks)) AS click_count,
sum(toFloat(metrics_impressions)) AS impression_count,
sum(toFloat(metrics_cost_micros)) / 1000000 AS total_cost,
- sum(toFloat(metrics_conversions)) AS conversion_count, 0 AS position_total
- FROM {stats}
+ sum(toFloat(metrics_conversions)) AS conversion_count, 0 AS position_total,
+ sumIf(toFloat({top_rate}) * toFloat(s.metrics_impressions), s.segments_ad_network_type = 'SEARCH') AS top_impressions,
+ sumIf(toFloat(s.metrics_impressions), s.segments_ad_network_type = 'SEARCH' AND {top_rate} IS NOT NULL) AS top_eligible_impressions,
+ sumIf(toFloat({absolute_top_rate}) * toFloat(s.metrics_impressions), s.segments_ad_network_type = 'SEARCH') AS absolute_top_impressions,
+ sumIf(toFloat(s.metrics_impressions), s.segments_ad_network_type = 'SEARCH' AND {absolute_top_rate} IS NOT NULL) AS absolute_top_eligible_impressions
+ FROM {stats} AS s
WHERE toDate(segments_date) >= toDate({date_from})
AND toDate(segments_date) <= toDate({date_to})
AND segments_ad_network_type IN ('SEARCH', 'SEARCH_PARTNERS')
@@ -148,7 +203,11 @@ class MarketingAnalyticsSearchQueryRunner(AnalyticsQueryRunner[MarketingAnalytic
sum(toFloat(s.metrics_clicks)) AS click_count,
sum(toFloat(s.metrics_impressions)) AS impression_count,
sum(toFloat(s.metrics_cost_micros)) / 1000000 AS total_cost,
- sum(toFloat(s.metrics_conversions)) AS conversion_count, 0 AS position_total
+ sum(toFloat(s.metrics_conversions)) AS conversion_count, 0 AS position_total,
+ sumIf(toFloat({top_rate}) * toFloat(s.metrics_impressions), s.segments_ad_network_type = 'SEARCH') AS top_impressions,
+ sumIf(toFloat(s.metrics_impressions), s.segments_ad_network_type = 'SEARCH' AND {top_rate} IS NOT NULL) AS top_eligible_impressions,
+ sumIf(toFloat({absolute_top_rate}) * toFloat(s.metrics_impressions), s.segments_ad_network_type = 'SEARCH') AS absolute_top_impressions,
+ sumIf(toFloat(s.metrics_impressions), s.segments_ad_network_type = 'SEARCH' AND {absolute_top_rate} IS NOT NULL) AS absolute_top_eligible_impressions
FROM {stats} AS s
LEFT JOIN (
SELECT customer_id, campaign_id, ad_group_id, ad_group_criterion_criterion_id,
@@ -171,8 +230,12 @@ class MarketingAnalyticsSearchQueryRunner(AnalyticsQueryRunner[MarketingAnalytic
SELECT {period} AS period, nullIf(lower(trim(keyword)), '') AS keyword, NULL AS page, 'BingAds' AS platform,
nullIf(lower(bid_match_type), '') AS matchType, nullIf(upper(currency_code), '') AS currency,
sum(toFloat(clicks)) AS click_count, sum(toFloat(impressions)) AS impression_count,
- sum(toFloat(spend)) AS total_cost, sum(toFloat(conversions)) AS conversion_count, 0 AS position_total
- FROM {stats}
+ sum(toFloat(spend)) AS total_cost, sum(toFloat(conversions)) AS conversion_count, 0 AS position_total,
+ sum({top_rate} * toFloat(s.impressions)) AS top_impressions,
+ sumIf(toFloat(s.impressions), {top_rate} IS NOT NULL) AS top_eligible_impressions,
+ sum({absolute_top_rate} * toFloat(s.impressions)) AS absolute_top_impressions,
+ sumIf(toFloat(s.impressions), {absolute_top_rate} IS NOT NULL) AS absolute_top_eligible_impressions
+ FROM {stats} AS s
WHERE toDate(time_period) >= toDate({date_from}) AND toDate(time_period) <= toDate({date_to})
GROUP BY keyword, matchType, currency
""",
@@ -203,7 +266,11 @@ class MarketingAnalyticsSearchQueryRunner(AnalyticsQueryRunner[MarketingAnalytic
if(platform = 'GoogleSearchConsole', NULL, sumIf(total_cost, period = 1) / nullIf(sumIf(click_count, period = 1), 0)) AS previous_cpc,
sumIf(total_cost, period = 1) / nullIf(sumIf(conversion_count, period = 1), 0) AS previous_cpa,
if(platform = 'GoogleSearchConsole', sumIf(position_total, period = 0) / nullIf(sumIf(impression_count, period = 0), 0), NULL) AS position,
- if(platform = 'GoogleSearchConsole', sumIf(position_total, period = 1) / nullIf(sumIf(impression_count, period = 1), 0), NULL) AS previous_position
+ if(platform = 'GoogleSearchConsole', sumIf(position_total, period = 1) / nullIf(sumIf(impression_count, period = 1), 0), NULL) AS previous_position,
+ sumIf(top_impressions, period = 0) / nullIf(sumIf(top_eligible_impressions, period = 0), 0) AS topImpressionRate,
+ sumIf(absolute_top_impressions, period = 0) / nullIf(sumIf(absolute_top_eligible_impressions, period = 0), 0) AS absoluteTopImpressionRate,
+ sumIf(top_impressions, period = 1) / nullIf(sumIf(top_eligible_impressions, period = 1), 0) AS previous_topImpressionRate,
+ sumIf(absolute_top_impressions, period = 1) / nullIf(sumIf(absolute_top_eligible_impressions, period = 1), 0) AS previous_absoluteTopImpressionRate
FROM {sources}
WHERE positionCaseInsensitive(coalesce(keyword, page, ''), {search}) > 0
GROUP BY keyword, page, platform, matchType, currency
@@ -219,6 +286,7 @@ class MarketingAnalyticsSearchQueryRunner(AnalyticsQueryRunner[MarketingAnalytic
result = execute_hogql_query(
query_type="marketing_analytics_search_query",
query=self.to_query(),
+ context=self.hogql_context,
team=self.team,
user=self.user,
timings=self.timings,
diff --git a/products/marketing_analytics/backend/hogql_queries/test_marketing_search_query_runner.py b/products/marketing_analytics/backend/hogql_queries/test_marketing_search_query_runner.py
index 23da4a323910..d966686e8a7a 100644
--- a/products/marketing_analytics/backend/hogql_queries/test_marketing_search_query_runner.py
+++ b/products/marketing_analytics/backend/hogql_queries/test_marketing_search_query_runner.py
@@ -63,17 +63,20 @@ class TestMarketingAnalyticsSearchQueryRunner(ClickhouseTestMixin, BaseTest):
"metrics_impressions": "Float64",
"metrics_cost_micros": "Float64",
"metrics_conversions": "Float64",
+ "metrics_top_impression_percentage": "Float64",
+ "metrics_absolute_top_impression_percentage": "Float64",
"segments_date": "Date",
"segments_ad_network_type": "String",
},
- "customer_id,campaign_id,ad_group_id,ad_group_criterion_criterion_id,customer_currency_code,metrics_clicks,metrics_impressions,metrics_cost_micros,metrics_conversions,segments_date,segments_ad_network_type\n"
- "1,10,100,7,USD,10,100,20000000,2,2023-01-10,SEARCH\n"
- "1,10,100,7,USD,30,900,40000000,0.5,2023-01-11,SEARCH_PARTNERS\n"
- "1,10,100,7,EUR,5,100,10000000,1,2023-01-10,SEARCH\n"
- "1,10,100,7,USD,900,9000,90000000,9,2023-01-10,CONTENT\n"
- "1,10,100,7,USD,20,200,30000000,1.25,2022-12-15,SEARCH\n"
- "1,10,100,7,USD,8,80,16000000,2,2022-01-10,SEARCH\n"
- "2,20,200,7,USD,3,100,6000000,1,2023-01-10,SEARCH\n",
+ "customer_id,campaign_id,ad_group_id,ad_group_criterion_criterion_id,customer_currency_code,metrics_clicks,metrics_impressions,metrics_cost_micros,metrics_conversions,segments_date,segments_ad_network_type,metrics_top_impression_percentage,metrics_absolute_top_impression_percentage\n"
+ "1,10,100,7,USD,4,40,8000000,0.8,2023-01-10,SEARCH,0.8,0.4\n"
+ "1,10,100,7,USD,6,60,12000000,1.2,2023-01-11,SEARCH,0.3,0.1\n"
+ "1,10,100,7,USD,30,900,40000000,0.5,2023-01-11,SEARCH_PARTNERS,0.99,0.99\n"
+ "1,10,100,7,EUR,5,100,10000000,1,2023-01-10,SEARCH,0.6,0.2\n"
+ "1,10,100,7,USD,900,9000,90000000,9,2023-01-10,CONTENT,0.99,0.99\n"
+ "1,10,100,7,USD,20,200,30000000,1.25,2022-12-15,SEARCH,0.6,0.2\n"
+ "1,10,100,7,USD,8,80,16000000,2,2022-01-10,SEARCH,0.6,0.2\n"
+ "2,20,200,7,USD,3,100,6000000,1,2023-01-10,SEARCH,0.6,0.2\n",
)
bing_stats = self._table(
"search_bing_stats",
@@ -86,12 +89,15 @@ class TestMarketingAnalyticsSearchQueryRunner(ClickhouseTestMixin, BaseTest):
"spend": "Float64",
"conversions": "Float64",
"time_period": "Date",
+ "top_impression_rate_percent": "String",
+ "absolute_top_impression_rate_percent": "String",
},
- "keyword,bid_match_type,currency_code,clicks,impressions,spend,conversions,time_period\n"
- "Hedgehog,Exact,USD,4,80,8,1,2023-01-10\n"
- "Hedgehog,Phrase,USD,1,20,2,0,2023-01-10\n"
- "Zero,Exact,USD,0,0,0,0,2023-01-10\n"
- "Previous only,Exact,USD,5,100,10,0.5,2022-12-15\n",
+ "keyword,bid_match_type,currency_code,clicks,impressions,spend,conversions,time_period,top_impression_rate_percent,absolute_top_impression_rate_percent\n"
+ "Hedgehog,Exact,USD,2,20,4,0.5,2023-01-10,80%,40%\n"
+ "Hedgehog,Exact,USD,2,60,4,0.5,2023-01-11,40,20\n"
+ "Hedgehog,Phrase,USD,1,20,2,0,2023-01-10,--,--\n"
+ "Zero,Exact,USD,0,0,0,0,2023-01-10,0,0\n"
+ "Previous only,Exact,USD,5,100,10,0.5,2022-12-15,60%,30%\n",
)
query = MarketingAnalyticsSearchQuery(
dateRange=DateRange(date_from="2023-01-01", date_to="2023-01-31"),
@@ -109,6 +115,8 @@ class TestMarketingAnalyticsSearchQueryRunner(ClickhouseTestMixin, BaseTest):
"keyword": "hedgehog",
"page": None,
"position": None,
+ "topImpressionRate": 0.5,
+ "absoluteTopImpressionRate": pytest.approx(0.22),
"platform": "GoogleAds",
"matchType": "exact",
"currency": "USD",
@@ -121,7 +129,15 @@ class TestMarketingAnalyticsSearchQueryRunner(ClickhouseTestMixin, BaseTest):
"cpa": 24,
"previous": None,
}
+ bing = next(
+ row for row in rows if row.platform == "BingAds" and row.matchType == "exact" and row.keyword == "hedgehog"
+ )
+ assert bing.topImpressionRate == pytest.approx(0.5)
+ assert bing.absoluteTopImpressionRate == pytest.approx(0.25)
+ missing = next(row for row in rows if row.platform == "BingAds" and row.matchType == "phrase")
+ assert missing.topImpressionRate is None and missing.absoluteTopImpressionRate is None
zero = next(row for row in rows if row.keyword == "zero")
+ assert zero.topImpressionRate is None and zero.absoluteTopImpressionRate is None
assert zero.ctr is None and zero.cpc is None and zero.cpa is None
assert next(row for row in rows if row.keyword == "other keyword").clicks == 3
query.search = "HEDGE"
@@ -149,11 +165,15 @@ class TestMarketingAnalyticsSearchQueryRunner(ClickhouseTestMixin, BaseTest):
"cpc": 1.5,
"cpa": 24,
"position": None,
+ "topImpressionRate": 0.6,
+ "absoluteTopImpressionRate": 0.2,
}
previous_only = next(row for row in compared if row.keyword == "previous only")
assert previous_only.clicks == 0
assert previous_only.ctr is None and previous_only.cpc is None and previous_only.cpa is None
assert previous_only.previous is not None and previous_only.previous.clicks == 5
+ assert previous_only.previous.topImpressionRate == pytest.approx(0.6)
+ assert previous_only.previous.absoluteTopImpressionRate == pytest.approx(0.3)
new_keyword = next(row for row in compared if row.keyword == "other keyword")
assert new_keyword.previous is not None and new_keyword.previous.clicks == 0
assert new_keyword.previous.ctr is None
@@ -171,9 +191,37 @@ class TestMarketingAnalyticsSearchQueryRunner(ClickhouseTestMixin, BaseTest):
assert previous_year.previous is not None and previous_year.previous.clicks == 8
assert not any(row.keyword == "previous only" for row in year_compared)
- @parameterized.expand([("GoogleAds",), ("BingAds",)])
- def test_landing_pages_exclude_non_search_traffic_and_keep_currencies(self, platform: str) -> None:
+ @parameterized.expand([("GoogleAds", True), ("GoogleAds", False), ("BingAds", False), ("BingAds", True)])
+ def test_landing_pages_exclude_non_search_traffic_and_keep_currencies(
+ self, platform: str, placement_available: bool
+ ) -> None:
if platform == "GoogleAds":
+ placement_columns = (
+ {
+ "metrics_top_impression_percentage": "Float64",
+ "metrics_absolute_top_impression_percentage": "Float64",
+ }
+ if placement_available
+ else {}
+ )
+ csv = (
+ "segments_date,landing_page_view_unexpanded_final_url,segments_ad_network_type,customer_currency_code,metrics_clicks,metrics_impressions,metrics_cost_micros,metrics_conversions\n"
+ "2023-01-10,https://example.com/a,SEARCH,USD,10,100,20000000,2\n"
+ "2023-01-11,https://example.com/a,SEARCH_PARTNERS,USD,5,50,10000000,0.5\n"
+ "2023-01-10,https://example.com/a,SEARCH,EUR,3,30,6000000,1\n"
+ "2023-01-10,https://example.com/a,CONTENT,USD,900,9000,90000000,90\n"
+ )
+ if placement_available:
+ lines = csv.splitlines()
+ csv = (
+ "\n".join(
+ [
+ lines[0] + ",metrics_top_impression_percentage,metrics_absolute_top_impression_percentage",
+ *(line + ",0.8,0.4" for line in lines[1:]),
+ ]
+ )
+ + "\n"
+ )
table = self._table(
"paid_landing_pages",
{
@@ -185,14 +233,35 @@ class TestMarketingAnalyticsSearchQueryRunner(ClickhouseTestMixin, BaseTest):
"metrics_impressions": "Float64",
"metrics_cost_micros": "Float64",
"metrics_conversions": "Float64",
+ **placement_columns,
},
- "segments_date,landing_page_view_unexpanded_final_url,segments_ad_network_type,customer_currency_code,metrics_clicks,metrics_impressions,metrics_cost_micros,metrics_conversions\n"
- "2023-01-10,https://example.com/a,SEARCH,USD,10,100,20000000,2\n"
- "2023-01-11,https://example.com/a,SEARCH_PARTNERS,USD,5,50,10000000,0.5\n"
- "2023-01-10,https://example.com/a,SEARCH,EUR,3,30,6000000,1\n"
- "2023-01-10,https://example.com/a,CONTENT,USD,900,9000,90000000,90\n",
+ csv,
)
else:
+ csv = (
+ "time_period,destination_url,ad_distribution,currency_code,clicks,impressions,spend,conversions_qualified\n"
+ "2023-01-10,https://example.com/a,Search,USD,10,100,20,2\n"
+ "2023-01-11,https://example.com/a,Search,USD,5,50,10,0.5\n"
+ "2023-01-10,https://example.com/a,Search,EUR,3,30,6,1\n"
+ "2023-01-10,https://example.com/a,Audience,USD,900,9000,90,90\n"
+ "2022-01-10,https://example.com/a,Search,USD,900,9000,90,90\n"
+ )
+ placement_columns = {}
+ if placement_available:
+ placement_columns = {
+ "top_impression_rate_percent": "String",
+ "absolute_top_impression_rate_percent": "String",
+ }
+ lines = csv.splitlines()
+ csv = (
+ "\n".join(
+ [
+ lines[0] + ",top_impression_rate_percent,absolute_top_impression_rate_percent",
+ *(line + ",80%,40%" for line in lines[1:]),
+ ]
+ )
+ + "\n"
+ )
table = self._table(
"bing_landing_pages",
{
@@ -204,13 +273,9 @@ class TestMarketingAnalyticsSearchQueryRunner(ClickhouseTestMixin, BaseTest):
"impressions": "Float64",
"spend": "Float64",
"conversions_qualified": "Float64",
+ **placement_columns,
},
- "time_period,destination_url,ad_distribution,currency_code,clicks,impressions,spend,conversions_qualified\n"
- "2023-01-10,https://example.com/a,Search,USD,10,100,20,2\n"
- "2023-01-11,https://example.com/a,Search,USD,5,50,10,0.5\n"
- "2023-01-10,https://example.com/a,Search,EUR,3,30,6,1\n"
- "2023-01-10,https://example.com/a,Audience,USD,900,9000,90,90\n"
- "2022-01-10,https://example.com/a,Search,USD,900,9000,90,90\n",
+ csv,
)
query = MarketingAnalyticsSearchQuery(
breakdown="page",
@@ -223,6 +288,8 @@ class TestMarketingAnalyticsSearchQueryRunner(ClickhouseTestMixin, BaseTest):
assert usd.page == "https://example.com/a" and usd.keyword is None
assert usd.clicks == 15 and usd.impressions == 150
assert usd.cost == 30 and usd.conversions == 2.5 and usd.position is None
+ assert usd.topImpressionRate == (0.8 if placement_available else None)
+ assert usd.absoluteTopImpressionRate == (0.4 if placement_available else None)
def test_organic_positions_are_weighted_and_details_keep_query_page_filters(self) -> None:
table = self._table(
diff --git a/products/marketing_analytics/frontend/dashboard/tables/ChangeValueCell.tsx b/products/marketing_analytics/frontend/dashboard/tables/ChangeValueCell.tsx
index 97c42a0c3b80..8f37a474b463 100644
--- a/products/marketing_analytics/frontend/dashboard/tables/ChangeValueCell.tsx
+++ b/products/marketing_analytics/frontend/dashboard/tables/ChangeValueCell.tsx
@@ -48,7 +48,10 @@ export function ChangeValueCell({
: getColorVar('danger')
const body = (
- <span className="inline-flex max-w-full flex-wrap items-center justify-end gap-1.5 tabular-nums">
+ <span
+ className="inline-flex max-w-full flex-wrap items-center justify-end gap-1.5 tabular-nums"
+ tabIndex={previous !== null || tooltipContent ? 0 : undefined}
+ >
<span>{current}</span>
{difference !== null && (
// eslint-disable-next-line react/forbid-dom-props
diff --git a/products/marketing_analytics/frontend/search/SearchPerformanceTab.stories.tsx b/products/marketing_analytics/frontend/search/SearchPerformanceTab.stories.tsx
index 95147071be03..72a9aba4695d 100644
--- a/products/marketing_analytics/frontend/search/SearchPerformanceTab.stories.tsx
+++ b/products/marketing_analytics/frontend/search/SearchPerformanceTab.stories.tsx
@@ -1,5 +1,5 @@
import { Meta, StoryObj } from '@storybook/react'
-import { within } from '@testing-library/dom'
+import { waitFor, within } from '@testing-library/dom'
import { BindLogic } from 'kea'
import { FEATURE_FLAGS } from 'lib/constants'
@@ -99,6 +99,8 @@ const ROWS: MarketingAnalyticsSearchRow[] = [
{
keyword: 'product analytics',
platform: 'GoogleAds',
+ topImpressionRate: 0.72,
+ absoluteTopImpressionRate: 0.38,
matchType: 'exact',
currency: 'USD',
clicks: 840,
@@ -112,6 +114,8 @@ const ROWS: MarketingAnalyticsSearchRow[] = [
{
keyword: 'website analytics',
platform: 'GoogleAds',
+ topImpressionRate: 0.72,
+ absoluteTopImpressionRate: 0.38,
matchType: 'phrase',
currency: 'USD',
clicks: 520,
@@ -125,6 +129,8 @@ const ROWS: MarketingAnalyticsSearchRow[] = [
{
keyword: 'product analytics',
platform: 'BingAds',
+ topImpressionRate: 0.64,
+ absoluteTopImpressionRate: 0.28,
matchType: 'exact',
currency: 'USD',
clicks: 240,
@@ -138,6 +144,8 @@ const ROWS: MarketingAnalyticsSearchRow[] = [
{
keyword: 'conversion tracking',
platform: 'BingAds',
+ topImpressionRate: 0.64,
+ absoluteTopImpressionRate: 0.28,
matchType: 'broad',
currency: 'EUR',
clicks: 80,
@@ -151,6 +159,8 @@ const ROWS: MarketingAnalyticsSearchRow[] = [
{
keyword: 'analytics dashboard',
platform: 'GoogleAds',
+ topImpressionRate: 0.72,
+ absoluteTopImpressionRate: 0.38,
matchType: 'exact',
currency: 'USD',
clicks: 0,
@@ -211,6 +221,12 @@ const MOCKS: Mocks = {
previous: query.compareFilter?.compare
? {
clicks: row.clicks * 0.8,
+ topImpressionRate:
+ row.topImpressionRate == null ? null : row.topImpressionRate - 0.08,
+ absoluteTopImpressionRate:
+ row.absoluteTopImpressionRate == null
+ ? null
+ : row.absoluteTopImpressionRate - 0.05,
position: row.position == null ? null : row.position + 1.5,
impressions: row.impressions * 0.9,
cost: row.cost == null ? null : row.cost * 1.1,
@@ -332,7 +348,9 @@ export const Comparison: Story = {
export const MixedWithPosition: Story = {
...Comparison,
play: async ({ canvasElement }) => {
- await userEvent.click(await within(canvasElement).findByRole('checkbox', { name: 'Show position' }))
+ const canvas = within(canvasElement)
+ await expect(await canvas.findByRole('columnheader', { name: /position|pos\./i })).toBeVisible()
+ await expect(canvas.queryByRole('checkbox', { name: 'Show position' })).not.toBeInTheDocument()
},
}
export const OrganicTraffic: Story = {
@@ -617,3 +635,61 @@ export const NewDashboardFlagOff: Story = {
featureFlags: [FEATURE_FLAGS.WEB_ANALYTICS_MARKETING, FEATURE_FLAGS.MARKETING_ANALYTICS_NEW_DASHBOARD],
},
}
+
+export const PositionMetrics: Story = {
+ ...Comparison,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement)
+ await expect(await canvas.findByRole('columnheader', { name: /position|pos\./i })).toBeVisible()
+ await expect(await canvas.findAllByText('72.0%')).not.toHaveLength(0)
+ await expect(await canvas.findAllByText('38.0%')).not.toHaveLength(0)
+ await expect(await canvas.findAllByText('64.0%')).not.toHaveLength(0)
+ await expect(await canvas.findAllByText('28.0%')).not.toHaveLength(0)
+ await expect(canvas.queryByRole('button', { name: 'Visibility' })).not.toBeInTheDocument()
+ const topLabel = (await canvas.findAllByText('Top'))[0]
+ topLabel.focus()
+ await userEvent.tab({ shift: true })
+ await userEvent.tab()
+ await expect(topLabel).toHaveFocus()
+ await waitFor(() =>
+ expect(
+ within(document.body).getByText(
+ 'Percentage of Google Search ad impressions shown among the top ads. Excludes Search partners. Requires a sync with ad placement data.'
+ )
+ ).toBeVisible()
+ )
+ await userEvent.tab()
+ await expect((await canvas.findAllByText('72.0%'))[0].parentElement).toHaveFocus()
+ await waitFor(() =>
+ expect(
+ within(document.body).getByText(
+ 'Percentage of Google Search ad impressions shown among the top ads. Excludes Search partners.'
+ )
+ ).toBeVisible()
+ )
+ await userEvent.tab()
+ const firstLabel = (await canvas.findAllByText('First'))[0]
+ await expect(firstLabel).toHaveFocus()
+ await waitFor(() =>
+ expect(
+ within(document.body).getByText(
+ 'Percentage of Google Search ad impressions shown as the first ad. Excludes Search partners. Requires a sync with ad placement data.'
+ )
+ ).toBeVisible()
+ )
+ await userEvent.keyboard('{Escape}')
+ firstLabel.blur()
+ await userEvent.hover(topLabel)
+ await waitFor(() =>
+ expect(
+ within(document.body).getByText(
+ 'Percentage of Google Search ad impressions shown among the top ads. Excludes Search partners. Requires a sync with ad placement data.'
+ )
+ ).toBeVisible()
+ )
+ },
+}
+export const NarrowPositionMetrics: Story = {
+ ...Narrow,
+ play: PositionMetrics.play,
+}
diff --git a/products/marketing_analytics/frontend/search/SearchPerformanceTab.tsx b/products/marketing_analytics/frontend/search/SearchPerformanceTab.tsx
index 049a26071aea..c87bab93990d 100644
--- a/products/marketing_analytics/frontend/search/SearchPerformanceTab.tsx
+++ b/products/marketing_analytics/frontend/search/SearchPerformanceTab.tsx
@@ -3,7 +3,6 @@ import { useActions, useValues } from 'kea'
import {
LemonBanner,
LemonButton,
- LemonCheckbox,
LemonInput,
LemonSegmentedButton,
LemonSelect,
@@ -29,15 +28,13 @@ export function SearchPerformanceTab(): JSX.Element {
readySources,
displayMetrics,
hasPaidSources,
- showPosition,
- canShowPosition,
search,
query,
breakdown,
channel,
hasActiveFilters,
} = useValues(searchPerformanceLogic)
- const { loadSources, setMetrics, setSearch, setBreakdown, setChannel, selectRow, setShowPosition, clearFilters } =
+ const { loadSources, setMetrics, setSearch, setBreakdown, setChannel, selectRow, clearFilters } =
useActions(searchPerformanceLogic)
const loading = !sourcesError && (dataWarehouseSourcesLoading || !dataWarehouseSources)
@@ -104,14 +101,6 @@ export function SearchPerformanceTab(): JSX.Element {
data-attr="marketing-search-keyword-filter"
/>
<div className="flex flex-wrap items-center gap-3">
- {canShowPosition && (
- <LemonCheckbox
- checked={showPosition}
- onChange={setShowPosition}
- label="Show position"
- data-attr="marketing-search-show-position"
- />
- )}
<LemonSegmentedButton
value={displayMetrics}
onChange={setMetrics}
@@ -131,7 +120,6 @@ export function SearchPerformanceTab(): JSX.Element {
<SearchPerformanceTable
query={query}
metrics={displayMetrics}
- showPosition={showPosition}
onSelect={selectRow}
emptyState={
<div className="flex flex-col items-center gap-2 py-4">
diff --git a/products/marketing_analytics/frontend/search/SearchPerformanceTable.tsx b/products/marketing_analytics/frontend/search/SearchPerformanceTable.tsx
index 72286d93c21d..7f31c30fa6c9 100644
--- a/products/marketing_analytics/frontend/search/SearchPerformanceTable.tsx
+++ b/products/marketing_analytics/frontend/search/SearchPerformanceTable.tsx
@@ -23,18 +23,17 @@ import { SourceIcon } from 'products/data_warehouse/frontend/shared/components/S
import { MarketingQueryError } from '../dashboard/MarketingQueryError'
import { ChangeValueCell } from '../dashboard/tables/ChangeValueCell'
import { SEARCH_PLATFORM_LABELS, SearchMetrics } from './searchPerformance'
+import { SearchPositionCell } from './SearchPositionCell'
export function SearchPerformanceTable({
query,
metrics,
- showPosition = false,
emptyState = 'No results match this date range. Try a wider date range.',
onSelect,
queryKey = 'marketing-search-performance',
}: {
query: MarketingAnalyticsSearchQuery
metrics: SearchMetrics
- showPosition?: boolean
emptyState?: React.ReactNode
onSelect?: (row: MarketingAnalyticsSearchRow) => void
queryKey?: string
@@ -48,15 +47,20 @@ export function SearchPerformanceTable({
const { loadData } = useActions(logic)
const rows = (response as MarketingAnalyticsSearchQueryResponse | undefined)?.results ?? []
const hasPaidSources = query.sources.some((source) => source.sourceType !== 'GoogleSearchConsole')
- const hasOrganicSources = query.sources.some((source) => source.sourceType === 'GoogleSearchConsole')
- const metricKeys: (keyof MarketingAnalyticsSearchMetrics)[] =
+ const hasPositionSources = query.sources.some((source) =>
+ ['GoogleSearchConsole', 'GoogleAds', 'BingAds'].includes(source.sourceType)
+ )
+ const metricKeys: Exclude<
+ keyof MarketingAnalyticsSearchMetrics,
+ 'topImpressionRate' | 'absoluteTopImpressionRate'
+ >[] =
metrics === 'traffic'
? [
'clicks',
'impressions',
'ctr',
...(hasPaidSources ? ['cost' as const] : []),
- ...(hasOrganicSources && (!hasPaidSources || showPosition) ? ['position' as const] : []),
+ ...(hasPositionSources ? ['position' as const] : []),
]
: ['cost', 'conversions', 'cpc', 'cpa']
@@ -181,13 +185,19 @@ export function SearchPerformanceTable({
cpc: 'Spend divided by clicks',
cpa: 'Spend divided by conversions',
position:
- 'Average position in organic Google search, weighted by impressions. Lower is better.',
+ 'Organic search position or paid search top and first-position impression percentages. Hover over a value for details.',
}[metric],
key: metric,
align: 'right' as const,
- sorter: (a: MarketingAnalyticsSearchRow, b: MarketingAnalyticsSearchRow) =>
- (a[metric] ?? -1) - (b[metric] ?? -1),
+ sorter:
+ metric === 'position' && hasPaidSources
+ ? undefined
+ : (a: MarketingAnalyticsSearchRow, b: MarketingAnalyticsSearchRow) =>
+ (a[metric] ?? -1) - (b[metric] ?? -1),
render: (_: unknown, row: MarketingAnalyticsSearchRow) => {
+ if (metric === 'position') {
+ return <SearchPositionCell row={row} compare={!!query.compareFilter?.compare} />
+ }
const value = row[metric] ?? null
const money = metric === 'cost' || metric === 'cpc' || metric === 'cpa'
const currency =
@@ -204,17 +214,12 @@ export function SearchPerformanceTable({
? 'percentage'
: money && currency
? 'currency'
- : metric === 'conversions' || metric === 'position' || money
+ : metric === 'conversions' || money
? 'decimal'
: 'number'
}
currency={currency ?? CurrencyCode.USD}
- reverseColors={
- metric === 'cost' ||
- metric === 'cpc' ||
- metric === 'cpa' ||
- metric === 'position'
- }
+ reverseColors={metric === 'cost' || metric === 'cpc' || metric === 'cpa'}
/>
{money && row.platform !== 'GoogleSearchConsole' && (
<span className="block text-xs text-secondary">
diff --git a/products/marketing_analytics/frontend/search/SearchPositionCell.tsx b/products/marketing_analytics/frontend/search/SearchPositionCell.tsx
new file mode 100644
index 000000000000..4721c01a95c9
--- /dev/null
+++ b/products/marketing_analytics/frontend/search/SearchPositionCell.tsx
@@ -0,0 +1,60 @@
+import { Tooltip } from 'lib/lemon-ui/Tooltip'
+
+import { CurrencyCode, MarketingAnalyticsSearchRow } from '~/queries/schema/schema-general'
+
+import { ChangeValueCell } from '../dashboard/tables/ChangeValueCell'
+
+export function SearchPositionCell({
+ row,
+ compare,
+}: {
+ row: MarketingAnalyticsSearchRow
+ compare: boolean
+}): JSX.Element {
+ if (row.platform === 'GoogleSearchConsole') {
+ return (
+ <ChangeValueCell
+ value={row.position == null ? null : [row.position, row.previous?.position ?? null]}
+ compare={compare}
+ kind="decimal"
+ currency={CurrencyCode.USD}
+ reverseColors
+ tooltipContent="Average position in organic Google search, weighted by impressions. Lower is better."
+ />
+ )
+ }
+ if (row.platform !== 'GoogleAds' && row.platform !== 'BingAds') {
+ return <span className="text-muted">–</span>
+ }
+ const searchName = row.platform === 'GoogleAds' ? 'Google Search' : 'Microsoft Advertising search'
+ const networkNote = row.platform === 'GoogleAds' ? ' Excludes Search partners.' : ''
+ return (
+ <div className="flex flex-col items-end gap-1">
+ {(
+ [
+ ['topImpressionRate', 'Top', `Percentage of ${searchName} ad impressions shown among the top ads.`],
+ [
+ 'absoluteTopImpressionRate',
+ 'First',
+ `Percentage of ${searchName} ad impressions shown as the first ad.`,
+ ],
+ ] as const
+ ).map(([metric, label, definition]) => (
+ <div key={metric} className="flex max-w-full flex-wrap items-center justify-end gap-x-1">
+ <Tooltip title={`${definition}${networkNote} Requires a sync with ad placement data.`}>
+ <span className="text-xs text-secondary" tabIndex={0}>
+ {label}
+ </span>
+ </Tooltip>
+ <ChangeValueCell
+ value={row[metric] == null ? null : [row[metric], row.previous?.[metric] ?? null]}
+ compare={compare}
+ kind="percentage"
+ currency={CurrencyCode.USD}
+ tooltipContent={`${definition}${networkNote}`}
+ />
+ </div>
+ ))}
+ </div>
+ )
+}
diff --git a/products/marketing_analytics/frontend/search/searchPerformanceLogic.ts b/products/marketing_analytics/frontend/search/searchPerformanceLogic.ts
index 2aaa02137259..f0bab63aa671 100644
--- a/products/marketing_analytics/frontend/search/searchPerformanceLogic.ts
+++ b/products/marketing_analytics/frontend/search/searchPerformanceLogic.ts
@@ -31,8 +31,6 @@ export interface searchPerformanceLogicValues extends Pick<
metrics: SearchMetrics
hasPaidSources: boolean
displayMetrics: SearchMetrics
- showPosition: boolean
- canShowPosition: boolean
breakdown: SearchBreakdown
channel: SearchChannel
selectedRow: MarketingAnalyticsSearchRow | null
@@ -57,7 +55,6 @@ export interface searchPerformanceLogicActions extends Pick<
'loadSources' | 'loadSourcesSuccess' | 'loadSourcesFailure' | 'setIntegrationFilter' | 'setDates'
> {
clearFilters: () => { value: true }
- setShowPosition: (showPosition: boolean) => { showPosition: boolean }
setMetrics: (metrics: SearchMetrics) => { metrics: SearchMetrics }
setBreakdown: (breakdown: SearchBreakdown) => { breakdown: SearchBreakdown }
setChannel: (channel: SearchChannel) => { channel: SearchChannel }
@@ -83,7 +80,6 @@ export const searchPerformanceLogic = kea<searchPerformanceLogicType>([
actions({
clearFilters: true,
setMetrics: (metrics: SearchMetrics) => ({ metrics }),
- setShowPosition: (showPosition: boolean) => ({ showPosition }),
setBreakdown: (breakdown: SearchBreakdown) => ({ breakdown }),
setChannel: (channel: SearchChannel) => ({ channel }),
selectRow: (row: MarketingAnalyticsSearchRow | null) => ({ row }),
@@ -97,7 +93,6 @@ export const searchPerformanceLogic = kea<searchPerformanceLogicType>([
null as MarketingAnalyticsSearchRow | null,
{ selectRow: (_, { row }) => row, setBreakdown: () => null, setChannel: () => null },
],
- showPosition: [false, { setShowPosition: (_, { showPosition }) => showPosition }],
metrics: ['traffic' as SearchMetrics, { setMetrics: (_, { metrics }) => metrics }],
search: ['', { setSearch: (_, { search }) => search }],
querySearch: ['', { setQuerySearch: (_, { search }) => search }],
@@ -171,13 +166,6 @@ export const searchPerformanceLogic = kea<searchPerformanceLogicType>([
(s) => [s.hasPaidSources, s.metrics],
(hasPaidSources: boolean, metrics: SearchMetrics): SearchMetrics => (hasPaidSources ? metrics : 'traffic'),
],
- canShowPosition: [
- (s) => [s.readySources, s.metrics],
- (sources: MarketingAnalyticsSearchSource[], metrics: SearchMetrics): boolean =>
- metrics === 'traffic' &&
- sources.some((source) => source.sourceType === 'GoogleSearchConsole') &&
- sources.some((source) => source.sourceType !== 'GoogleSearchConsole'),
- ],
query: [
(s) => [s.readySources, s.dateFilter, s.querySearch, s.compareFilter, s.breakdown],
(sources, dateFilter, search, compareFilter, breakdown): MarketingAnalyticsSearchQuery => ({
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/canonical_descriptions.py
index cea24158e37a..0f552efc3317 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/canonical_descriptions.py
@@ -48,6 +48,8 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"destination_url": "Destination URL after dynamic text substitution.",
"ad_distribution": "Distribution channel for the ad, such as Search or Audience.",
"conversions_qualified": "Conversions attributed to the ad, including fractional conversions.",
+ "top_impression_rate_percent": "Percentage of ad impressions shown above search results.",
+ "absolute_top_impression_rate_percent": "Percentage of ad impressions shown as the first ad.",
},
},
"campaigns": {
@@ -116,6 +118,8 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"docs_url": "https://learn.microsoft.com/en-us/advertising/reporting-service/keywordperformancereportrequest",
"columns": {
**_REPORT_METRICS,
+ "top_impression_rate_percent": "Percentage of ad impressions shown above search results.",
+ "absolute_top_impression_rate_percent": "Percentage of ad impressions shown as the first ad.",
"ad_group_id": "Identifier of the ad group the keyword belongs to.",
"ad_group_name": "Name of the ad group the keyword belongs to.",
"keyword": "The keyword text that triggered the ad.",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/schemas.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/schemas.py
index 7e03ca13ac0a..ceb204167a2b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/schemas.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bing_ads/schemas.py
@@ -64,6 +64,8 @@ RESOURCE_SCHEMAS: dict[BingAdsResource, dict] = {
"TimePeriod",
"Clicks",
"Impressions",
+ "TopImpressionRatePercent",
+ "AbsoluteTopImpressionRatePercent",
"Spend",
"ConversionsQualified",
],
@@ -231,6 +233,8 @@ RESOURCE_SCHEMAS: dict[BingAdsResource, dict] = {
"CurrencyCode",
"ExpectedCtr",
"Impressions",
+ "TopImpressionRatePercent",
+ "AbsoluteTopImpressionRatePercent",
"Keyword",
"KeywordId",
"KeywordStatus",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/canonical_descriptions.py
index e5513556f1f3..2f00a1d52143 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/canonical_descriptions.py
@@ -227,6 +227,8 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"docs_url": "https://developers.google.com/google-ads/api/fields/v17/keyword_view",
"columns": _stats_columns(
ad_group_criterion_criterion_id="Unique ID of the keyword criterion the metrics belong to.",
+ metrics_top_impression_percentage="Fraction of Google Search ad impressions shown among the top ads.",
+ metrics_absolute_top_impression_percentage="Fraction of Google Search ad impressions shown as the first ad.",
),
},
"video": {
@@ -559,6 +561,8 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"columns": _stats_columns(
**{
"landing_page_view_unexpanded_final_url": "The final URL as entered by the advertiser, before URL expansion.",
+ "metrics_top_impression_percentage": "Fraction of Google Search ad impressions shown among the top ads.",
+ "metrics_absolute_top_impression_percentage": "Fraction of Google Search ad impressions shown as the first ad.",
"metrics_speed_score": "Google's 0-100 estimate of how fast the landing page loads on mobile, relative to other pages.",
"metrics_mobile_friendly_clicks_percentage": "Percentage of mobile clicks that went to a mobile-friendly page.",
"metrics_valid_accelerated_mobile_pages_clicks_percentage": "Percentage of clicks to a landing page that is a valid AMP page.",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/schemas.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/schemas.py
index dfe0699e3a7d..d83ee71718ab 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/schemas.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/schemas.py
@@ -587,6 +587,8 @@ RESOURCE_SCHEMAS: dict[str, dict[str, Any]] = {
"metrics.gmail_saves",
"metrics.gmail_secondary_clicks",
"metrics.impressions",
+ "metrics.top_impression_percentage",
+ "metrics.absolute_top_impression_percentage",
"metrics.interaction_event_types",
"metrics.interaction_rate",
"metrics.interactions",
@@ -1243,6 +1245,8 @@ RESOURCE_SCHEMAS: dict[str, dict[str, Any]] = {
"customer.currency_code",
"metrics.clicks",
"metrics.impressions",
+ "metrics.top_impression_percentage",
+ "metrics.absolute_top_impression_percentage",
"metrics.cost_micros",
"metrics.conversions",
"metrics.conversions_value",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 3e79465f6458..5833a09ff32b 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -55337,6 +55337,8 @@ export namespace Schemas {
} as const;
export interface MarketingAnalyticsSearchMetrics {
+ /** Fraction of Google Search ad impressions shown as the first ad. */
+ absoluteTopImpressionRate?: number | null;
clicks: number;
conversions?: number | null;
cost?: number | null;
@@ -55345,9 +55347,13 @@ export namespace Schemas {
ctr?: number | null;
impressions: number;
position?: number | null;
+ /** Fraction of Google Search ad impressions shown among the top ads. */
+ topImpressionRate?: number | null;
}
export interface MarketingAnalyticsSearchRow {
+ /** Fraction of Google Search ad impressions shown as the first ad. */
+ absoluteTopImpressionRate?: number | null;
clicks: number;
conversions?: number | null;
cost?: number | null;
@@ -55362,6 +55368,8 @@ export namespace Schemas {
platform: Platform;
position?: number | null;
previous?: MarketingAnalyticsSearchMetrics | null;
+ /** Fraction of Google Search ad impressions shown among the top ads. */
+ topImpressionRate?: number | null;
}
export interface MarketingAnalyticsSearchQueryResponse {