Test page views
This commit is contained in:
parent
80ef6b85dd
commit
723ad59335
2 changed files with 11 additions and 10 deletions
|
|
@ -3,6 +3,7 @@ import { storeActions } from "@/constants/store-actions.js";
|
||||||
import { storeMutations } from "@/constants/store-mutations.js";
|
import { storeMutations } from "@/constants/store-mutations.js";
|
||||||
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
||||||
import { vehicleCategories } from "@/constants/vehicle-categories.js";
|
import { vehicleCategories } from "@/constants/vehicle-categories.js";
|
||||||
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
|
@ -41,23 +42,23 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
pushEventToGA(category, action, label, value) {
|
pushEventToGA(category, action, label, value, pageName) {
|
||||||
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': value,
|
||||||
'path': '/fmg/' + getQueryStringValue('fmgPage')
|
'path': `/fmg/?${queryStrings.FMG_PAGE}=${pageName}`
|
||||||
}
|
}
|
||||||
pushToDataLayerIfDefined(eventToBePushed);
|
pushToDataLayerIfDefined(eventToBePushed);
|
||||||
},
|
},
|
||||||
|
|
||||||
pushPageViewToGA() {
|
pushPageViewToGA(pageName) {
|
||||||
const pageViewEvent = {
|
const pageViewEvent = {
|
||||||
'event': 'logPageview',
|
'event': 'logPageview',
|
||||||
'pagePath': '/fmg/' + getQueryStringValue('fmgPage'),
|
'pagePath': `/fmg/?${queryStrings.FMG_PAGE}=${pageName}`,
|
||||||
'pageTitle': getQueryStringValue('fmgPage')
|
'pageTitle': pageName
|
||||||
};
|
};
|
||||||
pushToDataLayerIfDefined(pageViewEvent);
|
pushToDataLayerIfDefined(pageViewEvent);
|
||||||
}
|
}
|
||||||
|
|
@ -88,11 +89,6 @@ function encodeUriData(payload) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQueryStringValue(key) {
|
|
||||||
var queryStrings = new URLSearchParams(location.search);
|
|
||||||
return queryStrings.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
function pushToDataLayerIfDefined(data) {
|
function pushToDataLayerIfDefined(data) {
|
||||||
if (window.dataLayer !== undefined) {
|
if (window.dataLayer !== undefined) {
|
||||||
window.dataLayer.push(data);
|
window.dataLayer.push(data);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { storeActions } from "@/constants/store-actions";
|
||||||
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
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";
|
||||||
|
|
||||||
// Heritage integration
|
// Heritage integration
|
||||||
import { isSavedSessionStillActive } from "@/helpers/heritage-integration/session-helper";
|
import { isSavedSessionStillActive } from "@/helpers/heritage-integration/session-helper";
|
||||||
|
|
@ -120,6 +121,10 @@ const router = createRouter({
|
||||||
|
|
||||||
//---------------------------------------------------------- Router Functions ----------------------------------------------------------
|
//---------------------------------------------------------- Router Functions ----------------------------------------------------------
|
||||||
|
|
||||||
|
router.afterEach((to, from) => {
|
||||||
|
baseMixin.methods.pushPageViewToGA(to.query[queryStrings.FMG_PAGE]);
|
||||||
|
});
|
||||||
|
|
||||||
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => {
|
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => {
|
||||||
navigate(scenario, currentRoute, false, optionalQuery, optionalParams, optionalPageData);
|
navigate(scenario, currentRoute, false, optionalQuery, optionalParams, optionalPageData);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue