commit
77cf6e4ff5
4 changed files with 72 additions and 3 deletions
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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?.vin ? 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 ? true : false;
|
||||
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?.isItac;
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue