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 { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
||||
import { vehicleCategories } from "@/constants/vehicle-categories.js";
|
||||
import { queryStrings } from "@/constants/query-strings";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
|
|
@ -41,23 +42,23 @@ export default {
|
|||
}
|
||||
},
|
||||
|
||||
pushEventToGA(category, action, label, value) {
|
||||
pushEventToGA(category, action, label, value, pageName) {
|
||||
const eventToBePushed = {
|
||||
'event': 'ga_event',
|
||||
'category': category,
|
||||
'action': action,
|
||||
'label': label,
|
||||
'value': value,
|
||||
'path': '/fmg/' + getQueryStringValue('fmgPage')
|
||||
'path': `/fmg/?${queryStrings.FMG_PAGE}=${pageName}`
|
||||
}
|
||||
pushToDataLayerIfDefined(eventToBePushed);
|
||||
},
|
||||
|
||||
pushPageViewToGA() {
|
||||
pushPageViewToGA(pageName) {
|
||||
const pageViewEvent = {
|
||||
'event': 'logPageview',
|
||||
'pagePath': '/fmg/' + getQueryStringValue('fmgPage'),
|
||||
'pageTitle': getQueryStringValue('fmgPage')
|
||||
'pagePath': `/fmg/?${queryStrings.FMG_PAGE}=${pageName}`,
|
||||
'pageTitle': pageName
|
||||
};
|
||||
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) {
|
||||
if (window.dataLayer !== undefined) {
|
||||
window.dataLayer.push(data);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { storeActions } from "@/constants/store-actions";
|
|||
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
||||
import { routingTable } from "@/router/router-constants/routing-table.js";
|
||||
import { globalEvents, globalEventTypes } from "@/constants/events";
|
||||
import { queryStrings } from "@/constants/query-strings";
|
||||
|
||||
// Heritage integration
|
||||
import { isSavedSessionStillActive } from "@/helpers/heritage-integration/session-helper";
|
||||
|
|
@ -120,6 +121,10 @@ const router = createRouter({
|
|||
|
||||
//---------------------------------------------------------- Router Functions ----------------------------------------------------------
|
||||
|
||||
router.afterEach((to, from) => {
|
||||
baseMixin.methods.pushPageViewToGA(to.query[queryStrings.FMG_PAGE]);
|
||||
});
|
||||
|
||||
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => {
|
||||
navigate(scenario, currentRoute, false, optionalQuery, optionalParams, optionalPageData);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue