use experiment event to track CTA interaction (#56481) · github/docs@a0f20c7 · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Commit a0f20c7

Browse files
authored
use experiment event to track CTA interaction (#56481)
1 parent d41e28d commit a0f20c7

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/frame/components/page-footer/SupportSection.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ export const SupportSection = () => {
4848
)}
4949
>
5050
{showCopilotCTA && (
51-
<AISearchCTAPopup isOpen setIsSearchOpen={setIsSearchOpen} isDismissible={false} />
51+
<AISearchCTAPopup
52+
isOpen
53+
setIsSearchOpen={setIsSearchOpen}
54+
isDismissible={false}
55+
bannerType="footer"
56+
/>
5257
)}
5358
{showSurvey && <Survey />}
5459
{showContribution && <Contribution />}

src/search/components/input/AISearchCTAPopup.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { focusTrap } from '@primer/behaviors'
55
import { useTranslation } from '@/languages/components/useTranslation'
66
import { useMaxWidthBreakpoint, useMinWidthBreakpoint } from '../hooks/useBreakpoint'
77
import { useCTAPopoverContext } from '@/frame/components/context/CTAContext'
8+
import { sendEvent } from '@/events/components/events'
9+
import { EventType } from '@/events/types'
810

911
let previouslyFocused: HTMLElement | null = null
1012

@@ -13,11 +15,13 @@ export function AISearchCTAPopup({
1315
dismiss,
1416
setIsSearchOpen,
1517
isDismissible = true,
18+
bannerType = 'popover',
1619
}: {
1720
isOpen: boolean
1821
dismiss?: () => void
1922
setIsSearchOpen: (value: boolean) => void
2023
isDismissible?: boolean
24+
bannerType?: 'popover' | 'footer'
2125
}) {
2226
const { t } = useTranslation('search')
2327
const { permanentDismiss } = useCTAPopoverContext()
@@ -26,7 +30,21 @@ export function AISearchCTAPopup({
2630
let overlayRef = useRef<HTMLDivElement>(null)
2731
let dismissButtonRef = useRef<HTMLButtonElement>(null)
2832

33+
// Analytics helper functions
34+
const sendCTAAnalytics = (variation: 'dismiss' | 'ask_copilot') => {
35+
const experimentName =
36+
bannerType === 'footer' ? 'copilot_footer_banner' : 'copilot_popover_banner'
37+
sendEvent({
38+
type: EventType.experiment,
39+
experiment_name: experimentName,
40+
experiment_variation: variation,
41+
experiment_success: true,
42+
})
43+
}
44+
2945
const openSearch = () => {
46+
// Send analytics before taking action
47+
sendCTAAnalytics('ask_copilot')
3048
setIsSearchOpen(true)
3149
// They engaged with the CTA, so let's not show this popup for them anymore
3250
permanentDismiss()
@@ -47,6 +65,8 @@ export function AISearchCTAPopup({
4765
if (isTooSmallForCTA) {
4866
return
4967
}
68+
// Send analytics before taking action
69+
sendCTAAnalytics('dismiss')
5070
if (previouslyFocused) {
5171
previouslyFocused.focus()
5272
}

0 commit comments

Comments
 (0)

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.