Skip to content

Commit

Permalink
feat: add parity between ga4 and gtm for v1
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiago Neves committed Feb 6, 2024
1 parent 0bde52a commit 29711f9
Show file tree
Hide file tree
Showing 13 changed files with 1,205 additions and 194 deletions.
14 changes: 0 additions & 14 deletions packages/core/src/analytics/__fixtures__/trackData.fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,6 @@ export const customTrackMockData = {
checkoutOrderId: 12345678,
orderId: 'ABC12',
},
[eventTypes.REVIEW_CHECKOUT]: {
checkoutOrderId: 12345678,
coupon: 'PROMO_ABC',
currency: 'USD',
deliveryType: 'Standard/Standard',
interactionType: 'click',
method: 'guest',
orderId: 'ABC12',
packagingType: 'foo',
paymentType: 'credit',
shippingTier: 'Next Day',
step: 1,
tax: 1.23,
},
[eventTypes.SHIPPING_METHOD_ADDED]: {
step: '2',
deliveryType: 'Standard/Standard',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,17 +490,6 @@ export const trackEventsMapper = {
itemListName: data.properties?.list,
...getRecommendationsTrackingData(data),
}),
[eventTypes.REVIEW_CHECKOUT]: data => ({
tid: 3648,
...getCheckoutEventGenericProperties(data, true),
...getCommonCheckoutStepTrackingData(data),
basketValue: data.properties?.total,
basketCurrency: data.properties?.currency,
orderVAT: data.properties?.tax,
paymentType: data.properties?.paymentType,
promoCode: data.properties?.coupon,
shippingTotalValue: data.properties?.shipping,
}),
[eventTypes.CHECKOUT_ABANDONED]: data => ({
tid: 2084,
...getCheckoutEventGenericProperties(data, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,6 @@ Object {
}
`;

exports[`Omnitracking definitions \`Review Checkout\` return should match the snapshot 1`] = `
Object {
"basketCurrency": "USD",
"basketValue": 100,
"checkoutStep": 1,
"deliveryInformationDetails": "{\\"deliveryType\\":\\"Standard/Standard\\",\\"courierType\\":\\"Next Day\\",\\"packagingType\\":\\"foo\\"}",
"interactionType": "click",
"orderCode": "ABC12",
"orderId": 12345678,
"orderVAT": 1.23,
"paymentType": "credit",
"promoCode": "PROMO_ABC",
"shippingTotalValue": 10,
"tid": 3648,
}
`;

exports[`Omnitracking definitions \`Select Content\` return should match the snapshot 1`] = `
Object {
"contentType": "Navbar",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Object {
"PRODUCT_UPDATED_WISHLIST": "Product Updated In Wishlist",
"PRODUCT_VIEWED": "Product Viewed",
"PROMOCODE_APPLIED": "Promocode Applied",
"REVIEW_CHECKOUT": "Review Checkout",
"SELECT_CONTENT": "Select Content",
"SHARE": "Share",
"SHIPPING_INFO_ADDED": "Shipping Info Added",
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/analytics/types/eventTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ export default {
PRODUCT_VIEWED: 'Product Viewed',
/** Promocode Applied should be tracked when the user applies a promocode to a checkout. */
PROMOCODE_APPLIED: 'Promocode Applied',
/** Review Checkout should be tracked when the user reaches the review checkout page. */
REVIEW_CHECKOUT: 'Review Checkout',
/** Select Content should be tracked when the user selects a content, i.e., a product item. */
SELECT_CONTENT: 'Select Content',
/** Share should be tracked when the share feature is clicked. */
Expand Down
28 changes: 0 additions & 28 deletions packages/react/src/analytics/integrations/GA4/eventMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export default {
[eventTypes.FILTERS_CLEARED]: 'clear_all_filters',
[eventTypes.SHARE]: 'share',
[eventTypes.CHECKOUT_ABANDONED]: 'view_checkout_abandon_confirmation',
[eventTypes.REVIEW_CHECKOUT]: 'review_checkout',
[eventTypes.PLACE_ORDER_STARTED]: 'place_order',
[eventTypes.PROMOCODE_APPLIED]: 'apply_promo_code',
[eventTypes.CHECKOUT_STEP_EDITING]: 'edit_checkout_step',
Expand Down Expand Up @@ -476,30 +475,6 @@ const getCheckoutAbandonedParametersFromEvent = eventProperties => {
};
};

/**
* Returns the review checkout custom event parameters formatted for the GA4 event.
*
* @param {object} eventProperties - Properties from a track event.
*
* @returns {object} Parameters for the GA4's review checkout custom event.
*/
const getReviewCheckoutParametersFromEvent = eventProperties => {
return {
affiliation: eventProperties.affiliation,
checkout_step: eventProperties.step,
coupon: eventProperties.coupon,
currency: eventProperties.currency,
delivery_type: eventProperties.deliveryType,
packaging_type: eventProperties.packagingType,
payment_type: eventProperties.paymentType,
shipping_tier: eventProperties.shippingTier,
shipping: eventProperties.shipping,
tax: eventProperties.tax,
transaction_id: eventProperties.orderId,
value: eventProperties.total,
};
};

/**
* Returns the Interact Content parameters for the (custom) event.
*
Expand Down Expand Up @@ -875,9 +850,6 @@ export function getEventProperties(event, data) {
case eventTypes.CHECKOUT_ABANDONED:
return getCheckoutAbandonedParametersFromEvent(eventProperties);

case eventTypes.REVIEW_CHECKOUT:
return getReviewCheckoutParametersFromEvent(eventProperties);

case eventTypes.PLACE_ORDER_STARTED:
return getPlaceOrderStartedParametersFromEvent(eventProperties);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,6 @@ const placeOrderStartedSchema = currencyRequiredSchema
.concat(shippingSchema)
.concat(taxSchema);

const reviewCheckoutSchema = currencySchema
.concat(couponSchema)
.concat(totalSchema)
.concat(orderIdSchema)
.concat(affiliationSchema)
.concat(shippingSchema)
.concat(taxSchema)
.concat(deliveryTypeSchema)
.concat(packagingTypeSchema)
.concat(shippingTierSchema)
.concat(checkoutStepEditingSchema)
.concat(checkoutPaymentStepSchema);

const shippingMethodAddedSchema = checkoutShippingStepSchema;
const addressInfoAddedSchema = checkoutShippingStepSchema;

Expand Down Expand Up @@ -339,5 +326,4 @@ export default {
[eventTypes.PRODUCT_UPDATED]: productUpdatedSchema,
[eventTypes.INTERACT_CONTENT]: interactContentSchema,
[eventTypes.SIGNUP_NEWSLETTER]: signupNewsletterSchema,
[eventTypes.REVIEW_CHECKOUT]: reviewCheckoutSchema,
};
Loading

0 comments on commit 29711f9

Please sign in to comment.