From 8ab2a25fe4121acacc61d4aab61b352b1ba2de35 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Mon, 6 Oct 2025 15:38:18 -0400 Subject: [PATCH 1/3] CASH-1637 CASH-1637 - added 2 new analytics events to capture funnel data --- src/constants/analytics.js | 3 ++ src/mixins/analytics-mixin.js | 63 ++++++++++++++++++++++++++++++++ src/router/methods/after-each.js | 3 ++ src/store/index.js | 6 +-- 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/src/constants/analytics.js b/src/constants/analytics.js index fe43be06d..77bb78a3e 100644 --- a/src/constants/analytics.js +++ b/src/constants/analytics.js @@ -7,6 +7,8 @@ const analyticsPageEvents = { const GaEvents = { GENERIC_EVENT: "event", PAGE_VIEW_EVENT: "logPageview", + FMG_DATA_EVENT_1: "logEvent1", + FMG_DATA_EVENT_2: "logEvent2", }; const GaCategories = { @@ -14,6 +16,7 @@ const GaCategories = { EVOX: "Evox", APPOINTMENT: "Appointment", SERVICE_LOCATION: "service-location", + FMG_SESSION_DATA: "fmg_session_data", }; const GaActions = { diff --git a/src/mixins/analytics-mixin.js b/src/mixins/analytics-mixin.js index a3322a0a8..fe61ddeef 100644 --- a/src/mixins/analytics-mixin.js +++ b/src/mixins/analytics-mixin.js @@ -31,6 +31,9 @@ import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper"; import { routeData } from "@/router/constants/routes"; import { getQuerystringParameter } from "@/helpers/querystring-helper"; import { Variables } from "../constants/analytics"; +import { containsRecalParts, getRecalPartNumbers } from "@/helpers/recal-helper"; +import { getAmountDue, getSubTotal, getSalesTax } from "@/helpers/pricing-helper.js"; +import { partTypeStrings } from "@/constants/part-type-strings"; import router from "@/router"; export default { @@ -197,6 +200,66 @@ export default { await this.logPageView(analyticsPageEvents.ENTRY); }, + async pushFmgDataToGA() { + const hasSubmittedOrder = baseMixin.methods.hasSubmittedOrder(); + const submittedOrder = baseMixin.methods.getSubmittedOrder(); + const order = hasSubmittedOrder ? submittedOrder : store.getters.order; + + //event 1 + var label = {}; + label.carId = order?.vehicle?.carId; + label.hasVin = order?.vehicle ? true : false; + label.cashOrInsuranceAccountType = order?.payment?.isInsurance ? "Insurance" : "Cash"; + label.damageType = order?.damage?.isRepair ? "Repair" : "Replace"; + label.productType = order?.damage?.glassToReplace; + label.recalRequired = containsRecalParts(order?.lineItems); + label.recalType = getRecalPartNumbers(order?.lineItems?.glassParts); + label.serviceZipCode = order?.serviceLocation?.provider?.address?.zipCode + ? order?.serviceLocation?.provider?.address?.zipCode + : order?.serviceLocation?.zipCode; + label.providerCtu = order?.serviceLocation?.provider?.address?.zipCodeCtu + ? order?.serviceLocation?.provider?.address?.zipCodeCtu + : order?.serviceLocation?.zipCodeCtu; + label.subTotalPrice = getSubTotal(order?.lineItems); + label.totalPrice = getAmountDue(order?.lineItems); + + await this.pushEventToGA( + GaCategories.FMG_SESSION_DATA, + GaEvents.FMG_DATA_EVENT_1, + JSON.stringify(label), + true, + null, + null + ); + + //event 2 + const isEarlyBird = order?.lineItems?.supportingItems?.find( + (lineItem) => lineItem.partType == partTypeStrings.EARLY_BIRD + ); + + label = {}; + label.serviceType = order?.serviceLocation?.appointmentType; + label.promoCodes = order?.lineItems?.promos; + label.hasTechnicianNotes = order?.serviceLocation?.techNotes ? true : false; + label.paymentMethod = order?.payment?.piaType; + label.isTextingOptedIn = order?.customer?.isSmsOptIn ? true : false; + label.isEarlyBird = isEarlyBird; + label.insuranceCo = order?.policy?.insuranceCompanyName; + label.deductible = order?.policy?.currentDeductible; + label.isVerified = order?.payment?.insuranceCoverage?.isVerified; + label.isNoComp = order?.policy?.isNoComp; + label.isItac = order?.policy?.isNoComp; + + await this.pushEventToGA( + GaCategories.FMG_SESSION_DATA, + GaEvents.FMG_DATA_EVENT_2, + JSON.stringify(label), + true, + null, + null + ); + }, + pushOrderToDataLayer() { // helper check for if an object is defined (but maybe falsey) const isDefined = (x) => x !== null && x !== undefined; diff --git a/src/router/methods/after-each.js b/src/router/methods/after-each.js index 27cecffde..7be0e5ce0 100644 --- a/src/router/methods/after-each.js +++ b/src/router/methods/after-each.js @@ -12,4 +12,7 @@ export async function afterEach(to, from) { // Push current order status to Data Layer analyticsMixin.methods.pushOrderToDataLayer(); + + // Push session data GA events for Analytics + analyticsMixin.methods.pushFmgDataToGA(); } diff --git a/src/store/index.js b/src/store/index.js index ed84cc636..1fa9b4f14 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2960,9 +2960,9 @@ export const actions = { ) { const arrayOfLineItems = [ ...(pricedLineItems.glassParts ?? []), - ...pricedLineItems.promos, - ...pricedLineItems.supportingItems, - ...pricedLineItems.vaps, + ...(pricedLineItems.promos ?? []), + ...(pricedLineItems.supportingItems ?? []), + ...(pricedLineItems.vaps ?? []), ]; const flattenedLineItemsWithChildParts = getFlattenedArrayOfLineItemsWithChildParts(arrayOfLineItems); From 2ed7af2c7ad0eac5e97f625d8107e2838ff498eb Mon Sep 17 00:00:00 2001 From: CarlNation Date: Mon, 6 Oct 2025 15:44:51 -0400 Subject: [PATCH 2/3] CASH-1637 CASH-1637 bug cleanup --- src/mixins/analytics-mixin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mixins/analytics-mixin.js b/src/mixins/analytics-mixin.js index fe61ddeef..281515c3a 100644 --- a/src/mixins/analytics-mixin.js +++ b/src/mixins/analytics-mixin.js @@ -208,7 +208,7 @@ export default { //event 1 var label = {}; label.carId = order?.vehicle?.carId; - label.hasVin = order?.vehicle ? true : false; + label.hasVin = order?.vehicle?.vin ? true : false; label.cashOrInsuranceAccountType = order?.payment?.isInsurance ? "Insurance" : "Cash"; label.damageType = order?.damage?.isRepair ? "Repair" : "Replace"; label.productType = order?.damage?.glassToReplace; @@ -248,7 +248,7 @@ export default { label.deductible = order?.policy?.currentDeductible; label.isVerified = order?.payment?.insuranceCoverage?.isVerified; label.isNoComp = order?.policy?.isNoComp; - label.isItac = order?.policy?.isNoComp; + label.isItac = order?.policy?.isItac; await this.pushEventToGA( GaCategories.FMG_SESSION_DATA, From 6f5344c58331e14027e4b28a32a1953d3e4e6724 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Mon, 6 Oct 2025 15:50:28 -0400 Subject: [PATCH 3/3] CASH-1637 CASH-1637 correct earlybird --- src/mixins/analytics-mixin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mixins/analytics-mixin.js b/src/mixins/analytics-mixin.js index 281515c3a..74b74283b 100644 --- a/src/mixins/analytics-mixin.js +++ b/src/mixins/analytics-mixin.js @@ -243,7 +243,7 @@ export default { label.hasTechnicianNotes = order?.serviceLocation?.techNotes ? true : false; label.paymentMethod = order?.payment?.piaType; label.isTextingOptedIn = order?.customer?.isSmsOptIn ? true : false; - label.isEarlyBird = isEarlyBird; + label.isEarlyBird = isEarlyBird ? true : false; label.insuranceCo = order?.policy?.insuranceCompanyName; label.deductible = order?.policy?.currentDeductible; label.isVerified = order?.payment?.insuranceCoverage?.isVerified;