GA events
This commit is contained in:
parent
c0290c43ee
commit
a6f8a6289e
7 changed files with 79 additions and 36 deletions
|
|
@ -134,7 +134,8 @@ export default {
|
||||||
return answer.Name ? answer.Name : answer;
|
return answer.Name ? answer.Name : answer;
|
||||||
},
|
},
|
||||||
handleCheckedChanged(val) {
|
handleCheckedChanged(val) {
|
||||||
this.pushEventToGA(this.$route.query[queryStrings.FMG_PAGE], 'Clicked', val.value, undefined, this.$route.query[queryStrings.FMG_PAGE]);
|
|
||||||
|
this.pushEventToGA(this.$route.query[queryStrings.FMG_PAGE], this.analyticsActions.CLICKED, val.value, true);
|
||||||
|
|
||||||
if(this.isMultiSelect && this.selectedValues) {
|
if(this.isMultiSelect && this.selectedValues) {
|
||||||
// Add or remove item to array of data to emit
|
// Add or remove item to array of data to emit
|
||||||
|
|
|
||||||
22
src/constants/analytics-events.js
Normal file
22
src/constants/analytics-events.js
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
const analyticsPageEvents = {
|
||||||
|
ENTRY: "ENTRY",
|
||||||
|
EVENT: "EVENT"
|
||||||
|
};
|
||||||
|
|
||||||
|
const analyticsCategories = {
|
||||||
|
API_RESPONSE: 'Api_Response',
|
||||||
|
EVOX: 'Evox'
|
||||||
|
};
|
||||||
|
|
||||||
|
const analyticsActions = {
|
||||||
|
RESULT: 'Result',
|
||||||
|
CLICKED: 'Clicked',
|
||||||
|
VIF: 'vif'
|
||||||
|
};
|
||||||
|
|
||||||
|
const analyticsLabels = {
|
||||||
|
SUCCESS: 'Success',
|
||||||
|
ERROR: 'Error'
|
||||||
|
};
|
||||||
|
|
||||||
|
export { analyticsPageEvents, analyticsCategories, analyticsActions, analyticsLabels};
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
const analyticsPageEvents = {
|
|
||||||
ENTRY: "ENTRY",
|
|
||||||
EVENT: "EVENT"
|
|
||||||
};
|
|
||||||
|
|
||||||
export { analyticsPageEvents };
|
|
||||||
|
|
@ -1,16 +1,13 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { applicationConfig } from "@/constants/application-config.js";
|
import { applicationConfig } from "@/constants/application-config.js";
|
||||||
|
import { analyticsCategories, analyticsActions,analyticsLabels} from "@/constants/analytics-events";
|
||||||
|
import analyticsMixIn from "@/mixins/analytics-mixin.js";
|
||||||
import httpStatusCodes from "http-status-codes";
|
import httpStatusCodes from "http-status-codes";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
callHttpClient({ method, endpoint, payload }) {
|
callHttpClient({ method, endpoint, payload }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
var apiGatewayUrl = applicationConfig.CONSUMER_APIGATEWAY_URL;
|
const apiGatewayUrl = applicationConfig.CONSUMER_APIGATEWAY_URL;
|
||||||
|
|
||||||
if(endpoint.includes('analytics')){
|
|
||||||
apiGatewayUrl = 'https://localhost:44324';
|
|
||||||
}
|
|
||||||
|
|
||||||
const payloadAndAnalyticsData = Object.assign({}, payload, {
|
const payloadAndAnalyticsData = Object.assign({}, payload, {
|
||||||
AppName: "FixMyGlass",
|
AppName: "FixMyGlass",
|
||||||
});
|
});
|
||||||
|
|
@ -24,17 +21,24 @@ export default {
|
||||||
}).then(
|
}).then(
|
||||||
(response) => {
|
(response) => {
|
||||||
if (response.status == httpStatusCodes.OK) {
|
if (response.status == httpStatusCodes.OK) {
|
||||||
if(response.data == undefined) {
|
if (response.data == undefined) {
|
||||||
reject(response);
|
analyticsMixIn.methods.pushEventToGA(analyticsCategories.API_RESPONSE, analyticsActions.RESULT,
|
||||||
}else{
|
`${analyticsLabels.ERROR}_${endpoint}`, true);
|
||||||
resolve(response);
|
|
||||||
|
return reject(response);
|
||||||
|
} else {
|
||||||
|
analyticsMixIn.methods.pushEventToGA(analyticsCategories.API_RESPONSE, analyticsActions.RESULT,
|
||||||
|
`${analyticsLabels.SUCCESS}_${endpoint}`, true);
|
||||||
|
|
||||||
|
return resolve(response);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
reject(response);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
analyticsMixIn.methods.pushEventToGA(analyticsCategories.API_RESPONSE, analyticsActions.RESULT,
|
||||||
|
`${analyticsLabels.ERROR}_${endpoint}`, true);
|
||||||
|
|
||||||
return reject(error.response);
|
return reject(error.response);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,8 @@ export default {
|
||||||
},
|
},
|
||||||
mounted(){
|
mounted(){
|
||||||
if(this.$store.getters.vehicle.imageVifNumber){
|
if(this.$store.getters.vehicle.imageVifNumber){
|
||||||
this.pushEventToGA("Evox", `vif_${this.$store.getters.vehicle.imageVifNumber}`, this.$store.getters.vehicle.carId, undefined, this.$route.query[queryStrings.FMG_PAGE]);
|
this.pushEventToGA(this.analyticsCategories.EVOX, `${this.analyticsActions.VIF}_${this.$store.getters.vehicle.imageVifNumber}`,
|
||||||
|
this.$store.getters.vehicle.carId, true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import baseMixin from "@/mixins/base-mixin";
|
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
|
||||||
import { getDeviceIdValue, getSessionIdValue, getSessionKeyValue } from "@/helpers/heritage-integration/cookie-helper";
|
import { getDeviceIdValue, getSessionIdValue, getSessionKeyValue } from "@/helpers/heritage-integration/cookie-helper";
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
import { analyticsPageEvents } from "@/constants/analytics-page-events";
|
import { analyticsPageEvents, analyticsCategories, analyticsActions, analyticsLabels } from "@/constants/analytics-events";
|
||||||
import { experimentSettings } from "@/constants/experiments";
|
import { experimentSettings } from "@/constants/experiments";
|
||||||
|
|
||||||
|
import baseMixin from "@/mixins/base-mixin";
|
||||||
|
|
||||||
|
// We will need current page name for multiple methods, define it once to re-use.
|
||||||
|
const currentPageName = getPageNameByQueryString();
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
logEvent(destinationFmgPageValue, pageEvent, category, action, label, value){
|
logEvent(destinationFmgPageValue, pageEvent, category, action, label, value){
|
||||||
|
|
@ -28,31 +31,33 @@ export default {
|
||||||
baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.LOG_ACTIVITY, payload, false);
|
baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.LOG_ACTIVITY, payload, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
pushEventToGA(category, action, label, value, pageName, pushToLogApp) {
|
pushEventToGA(category, action, label, pushToLogApp = false) {
|
||||||
const eventToBePushed = {
|
const eventToBePushed = {
|
||||||
'event': 'ga_event',
|
'event': 'ga_event',
|
||||||
'category': category,
|
'category': category,
|
||||||
'action': action,
|
'action': action,
|
||||||
'label': label,
|
'label': label,
|
||||||
'value': value,
|
'value': undefined,
|
||||||
'path': `/fmg/?${queryStrings.FMG_PAGE}=${pageName}`
|
'path': `/fmg/?${queryStrings.FMG_PAGE}=${currentPageName}`
|
||||||
}
|
}
|
||||||
|
|
||||||
pushToDataLayerIfDefined(eventToBePushed);
|
pushToDataLayerIfDefined(eventToBePushed);
|
||||||
|
|
||||||
if (pushToLogApp) {
|
if (pushToLogApp) {
|
||||||
this.logEvent(pageName, null, category, action, label, value);
|
this.logEvent(currentPageName, undefined, category, action, label, undefined);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
pushPageViewToGA(pageName) {
|
pushPageViewToGA() {
|
||||||
const pageViewEvent = {
|
const pageViewEvent = {
|
||||||
'event': 'logPageview',
|
'event': 'logPageview',
|
||||||
'pagePath': `/fmg/?${queryStrings.FMG_PAGE}=${pageName}`,
|
'pagePath': `/fmg/?${queryStrings.FMG_PAGE}=${currentPageName}`,
|
||||||
'pageTitle': pageName
|
'pageTitle': currentPageName
|
||||||
};
|
};
|
||||||
|
|
||||||
pushToDataLayerIfDefined(pageViewEvent);
|
pushToDataLayerIfDefined(pageViewEvent);
|
||||||
|
|
||||||
|
this.logEvent(currentPageName, analyticsPageEvents.ENTRY);
|
||||||
},
|
},
|
||||||
|
|
||||||
pushExperimentsToDataLayer(experiments){
|
pushExperimentsToDataLayer(experiments){
|
||||||
|
|
@ -75,19 +80,36 @@ export default {
|
||||||
// Push to the data layer with the Google Custom Dimension Index.
|
// Push to the data layer with the Google Custom Dimension Index.
|
||||||
pushToDataLayerIfDefined(experimentWithDimension);
|
pushToDataLayerIfDefined(experimentWithDimension);
|
||||||
});
|
});
|
||||||
},
|
|
||||||
this.logEvent(pageName, analyticsPageEvents.ENTRY);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
storeActions() {
|
analyticsPageEvents() {
|
||||||
return storeActions;
|
return analyticsPageEvents;
|
||||||
},
|
},
|
||||||
},
|
analyticsCategories() {
|
||||||
|
return analyticsCategories;
|
||||||
|
},
|
||||||
|
analyticsActions() {
|
||||||
|
return analyticsActions;
|
||||||
|
},
|
||||||
|
analyticsLabels() {
|
||||||
|
return analyticsLabels;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function pushToDataLayerIfDefined(data) {
|
function pushToDataLayerIfDefined(data) {
|
||||||
if (window.dataLayer !== undefined) {
|
if (window.dataLayer !== undefined) {
|
||||||
window.dataLayer.push(data);
|
window.dataLayer.push(data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPageNameByQueryString() {
|
||||||
|
const params = new URLSearchParams(location.search);
|
||||||
|
|
||||||
|
if(params.has(queryStrings.FMG_PAGE)) {
|
||||||
|
return params.get(queryStrings.FMG_PAGE);
|
||||||
|
}else{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,7 +5,6 @@ import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js"
|
||||||
import { routingTable } from "@/router/router-constants/routing-table.js";
|
import { routingTable } from "@/router/router-constants/routing-table.js";
|
||||||
import { globalEvents, globalEventTypes } from "@/constants/events";
|
import { globalEvents, globalEventTypes } from "@/constants/events";
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
import { analyticsPageEvents } from "./router-constants/analytics-page-events";
|
|
||||||
import { getDeviceIdValue } from "@/helpers/heritage-integration/cookie-helper";
|
import { getDeviceIdValue } from "@/helpers/heritage-integration/cookie-helper";
|
||||||
|
|
||||||
// Heritage integration
|
// Heritage integration
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue