Update in-app product card clicked Tracks event (#51180)

* Add product and group id properties to Tracks data for product card clicks

* Add changefile(s) from automation for the following project(s): woocommerce

* Update product tracksproperty to product_id

Co-authored-by: And Finally <andfinally@users.noreply.github.com>

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: And Finally <andfinally@users.noreply.github.com>
This commit is contained in:
Herman 2024-09-10 08:33:12 +02:00 committed by GitHub
parent 7dc26a8c66
commit 3b35e22c99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 1 deletions

View File

@ -31,6 +31,7 @@ function ProductCard( props: ProductCardProps ): JSX.Element {
const query = useQuery();
// Get the product if provided; if not provided, render a skeleton loader
const product = props.product ?? {
id: null,
title: '',
description: '',
vendorName: '',
@ -81,6 +82,10 @@ function ProductCard( props: ProductCardProps ): JSX.Element {
data.group = tracksData.group;
}
if ( tracksData.group_id ) {
data.group_id = tracksData.group_id;
}
if ( tracksData.searchTerm ) {
data.search_term = tracksData.searchTerm;
}
@ -142,7 +147,8 @@ function ProductCard( props: ProductCardProps ): JSX.Element {
rel="noopener noreferrer"
onClick={ () => {
recordTracksEvent( 'marketplace_product_card_clicked', {
product: product.title,
product_id: product.id,
product_name: product.title,
vendor: product.vendorName,
product_type: type,
} );

View File

@ -111,6 +111,9 @@ export default function ProductListContent( props: {
...( product.label && {
label: product.label,
} ),
...( props.productGroup && {
group_id: props.productGroup,
} ),
...( props.group && { group: props.group } ),
...( props.searchTerm && {
searchTerm: props.searchTerm,

View File

@ -58,6 +58,7 @@ export interface ProductTracksData {
position?: number;
label?: string;
group?: string;
group_id?: string;
searchTerm?: string;
category?: string;
}

View File

@ -0,0 +1,4 @@
Significance: patch
Type: tweak
Include group and product id properties in the `marketplace_product_card_clicked` Tracks event