Skip to content

Commit 74d79d4

Browse files
committed
Stats pricing grid: add view and CTA analytics events
stats_pricing_grid_view fires on mount, stats_pricing_grid_paid_cta_clicked and stats_pricing_grid_free_cta_clicked on the two CTAs — all through trackStatsAnalyticsEvent (which prefixes jetpack_odyssey_/calypso_ by surface) and all carrying blog_id, following the pattern from #113364. The purchase page's skip button already has its own event.
1 parent a38e1c2 commit 74d79d4

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

client/my-sites/stats/pricing-grid/pricing-grid.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import { createInterpolateElement } from '@wordpress/element';
88
import { Icon, check, closeSmall } from '@wordpress/icons';
99
import clsx from 'clsx';
1010
import { useTranslate } from 'i18n-calypso';
11+
import { useEffect } from 'react';
1112
import DocumentHead from 'calypso/components/data/document-head';
1213
import Main from 'calypso/my-sites/stats/components/stats-main';
1314
import { STATS_PRODUCT_NAME } from 'calypso/my-sites/stats/constants';
15+
import { trackStatsAnalyticsEvent } from 'calypso/my-sites/stats/utils';
1416
import { useSelector } from 'calypso/state';
1517
import { getProductBySlug } from 'calypso/state/products-list/selectors';
1618
import { getSiteSlug } from 'calypso/state/sites/selectors';
@@ -51,6 +53,10 @@ export default function PricingGrid( { onDismiss }: PricingGridProps ) {
5153
const siteSlug = useSelector( ( state ) => getSiteSlug( state, siteId ) );
5254
const dismissPricingGrid = useDismissPricingGrid( siteId );
5355

56+
useEffect( () => {
57+
trackStatsAnalyticsEvent( 'stats_pricing_grid_view', { blog_id: siteId } );
58+
}, [ siteId ] );
59+
5460
const product = useSelector( ( state ) =>
5561
getProductBySlug( state, PRODUCT_JETPACK_STATS_YEARLY )
5662
) as ProductsList.RawAPIProduct | null;
@@ -130,6 +136,7 @@ export default function PricingGrid( { onDismiss }: PricingGridProps ) {
130136

131137
// Starting for free is a plan choice: record the dismissal and reveal the dashboard.
132138
const startForFree = () => {
139+
trackStatsAnalyticsEvent( 'stats_pricing_grid_free_cta_clicked', { blog_id: siteId } );
133140
dismissPricingGrid();
134141
onDismiss?.();
135142
};
@@ -140,6 +147,7 @@ export default function PricingGrid( { onDismiss }: PricingGridProps ) {
140147
// programmatically rather than via href so the link also works under Odyssey's
141148
// hashbang routing when the wp-admin click shim doesn't apply (e.g. middle-click).
142149
const goToPurchase = () => {
150+
trackStatsAnalyticsEvent( 'stats_pricing_grid_paid_cta_clicked', { blog_id: siteId } );
143151
page( `/stats/purchase/${ siteSlug }?from=${ PRICING_GRID_REFERRER }` );
144152
};
145153

0 commit comments

Comments
 (0)