CASH-1637
CASH-1637 - added 2 new analytics events to capture funnel data
This commit is contained in:
parent
39f9fb9cc4
commit
8ab2a25fe4
4 changed files with 72 additions and 3 deletions
|
|
@ -7,6 +7,8 @@ const analyticsPageEvents = {
|
||||||
const GaEvents = {
|
const GaEvents = {
|
||||||
GENERIC_EVENT: "event",
|
GENERIC_EVENT: "event",
|
||||||
PAGE_VIEW_EVENT: "logPageview",
|
PAGE_VIEW_EVENT: "logPageview",
|
||||||
|
FMG_DATA_EVENT_1: "logEvent1",
|
||||||
|
FMG_DATA_EVENT_2: "logEvent2",
|
||||||
};
|
};
|
||||||
|
|
||||||
const GaCategories = {
|
const GaCategories = {
|
||||||
|
|
@ -14,6 +16,7 @@ const GaCategories = {
|
||||||
EVOX: "Evox",
|
EVOX: "Evox",
|
||||||
APPOINTMENT: "Appointment",
|
APPOINTMENT: "Appointment",
|
||||||
SERVICE_LOCATION: "service-location",
|
SERVICE_LOCATION: "service-location",
|
||||||
|
FMG_SESSION_DATA: "fmg_session_data",
|
||||||
};
|
};
|
||||||
|
|
||||||
const GaActions = {
|
const GaActions = {
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,9 @@ import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
|
||||||
import { routeData } from "@/router/constants/routes";
|
import { routeData } from "@/router/constants/routes";
|
||||||
import { getQuerystringParameter } from "@/helpers/querystring-helper";
|
import { getQuerystringParameter } from "@/helpers/querystring-helper";
|
||||||
import { Variables } from "../constants/analytics";
|
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";
|
import router from "@/router";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
@ -197,6 +200,66 @@ export default {
|
||||||
await this.logPageView(analyticsPageEvents.ENTRY);
|
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() {
|
pushOrderToDataLayer() {
|
||||||
// helper check for if an object is defined (but maybe falsey)
|
// helper check for if an object is defined (but maybe falsey)
|
||||||
const isDefined = (x) => x !== null && x !== undefined;
|
const isDefined = (x) => x !== null && x !== undefined;
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,7 @@ export async function afterEach(to, from) {
|
||||||
|
|
||||||
// Push current order status to Data Layer
|
// Push current order status to Data Layer
|
||||||
analyticsMixin.methods.pushOrderToDataLayer();
|
analyticsMixin.methods.pushOrderToDataLayer();
|
||||||
|
|
||||||
|
// Push session data GA events for Analytics
|
||||||
|
analyticsMixin.methods.pushFmgDataToGA();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2960,9 +2960,9 @@ export const actions = {
|
||||||
) {
|
) {
|
||||||
const arrayOfLineItems = [
|
const arrayOfLineItems = [
|
||||||
...(pricedLineItems.glassParts ?? []),
|
...(pricedLineItems.glassParts ?? []),
|
||||||
...pricedLineItems.promos,
|
...(pricedLineItems.promos ?? []),
|
||||||
...pricedLineItems.supportingItems,
|
...(pricedLineItems.supportingItems ?? []),
|
||||||
...pricedLineItems.vaps,
|
...(pricedLineItems.vaps ?? []),
|
||||||
];
|
];
|
||||||
const flattenedLineItemsWithChildParts =
|
const flattenedLineItemsWithChildParts =
|
||||||
getFlattenedArrayOfLineItemsWithChildParts(arrayOfLineItems);
|
getFlattenedArrayOfLineItemsWithChildParts(arrayOfLineItems);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue