Skip to content

Commit

Permalink
📈 Add more gre events
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Nov 15, 2024
1 parent 8aa5be3 commit c79e9dd
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/pages/store/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ export default {
name: item.title,
price: item.minPrice,
})),
search_term: this.searchQuery || this.selectedTagTitle,
search_term: this.searchQuery || undefined,
isNFTBook: true,
});
},
Expand Down Expand Up @@ -1300,7 +1300,6 @@ export default {
price: item.minPrice,
currency: 'USD',
})),
search_term: tag.name,
isNFTBook: true,
});
},
Expand Down
62 changes: 62 additions & 0 deletions src/util/EventLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,68 @@ export function logPurchaseFlowEvent(
);
}
}
if (vue.$gre) {
const productDetails = items?.map(i => {
let itemId = i.productId || i.collectionId || i.classId;
if (i.priceIndex !== undefined) {
itemId = `${itemId}-${i.priceIndex}`;
}
return {
product: { id: itemId },
quantity: i.quantity || 1,
};
});
switch (event) {
case 'view_item_list': {
if (otherPayload.search_term) {
vue.$gre.logEvent('search', {
searchQuery: otherPayload.search_term,
pageCategories: ['eBook'],
productDetails,
});
} else if (otherPayload.list_id !== 'listing') {
vue.$gre.logEvent('category-page-view', {
pageCategories: [`eBook > ${otherPayload.list_id}`],
productDetails,
});
}
break;
}
case 'view_item': {
vue.$gre.logEvent('detail-page-view', {
productDetails,
});
break;
}
case 'add_to_cart': {
vue.$gre.logEvent('add-to-cart', {
cartId: paymentId,
productDetails,
});
break;
}
case 'view_cart': {
vue.$gre.logEvent('shopping-cart-view', {
cartId: paymentId,
productDetails,
});
break;
}
case 'purchase': {
vue.$gre.logEvent('purchase-complete', {
cartId: paymentId,
productDetails,
purchaseTransaction: {
revenue: price,
currencyCode: currency,
},
});
break;
}
default:
break;
}
}
if (vue.$crisp) {
vue.$crisp.push([
'set',
Expand Down

0 comments on commit c79e9dd

Please sign in to comment.