GA event methods
This commit is contained in:
parent
ec47baea6f
commit
80ef6b85dd
1 changed files with 37 additions and 4 deletions
|
|
@ -11,10 +11,10 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setCmsContent(cmsContent){
|
setCmsContent(cmsContent) {
|
||||||
this.$root.cmsContentByWidget = cmsContent;
|
this.$root.cmsContentByWidget = cmsContent;
|
||||||
},
|
},
|
||||||
getCmsContent(widgetName, fieldName){
|
getCmsContent(widgetName, fieldName) {
|
||||||
return this.$root.cmsContentByWidget?.[widgetName]?.[fieldName] ? this.$root.cmsContentByWidget[widgetName][fieldName] : '';
|
return this.$root.cmsContentByWidget?.[widgetName]?.[fieldName] ? this.$root.cmsContentByWidget[widgetName][fieldName] : '';
|
||||||
},
|
},
|
||||||
dispatchNonBlockingStoreAction(type, payload, encodePayload = true) {
|
dispatchNonBlockingStoreAction(type, payload, encodePayload = true) {
|
||||||
|
|
@ -25,10 +25,10 @@ export default {
|
||||||
|
|
||||||
return store.dispatch(type, payload);
|
return store.dispatch(type, payload);
|
||||||
},
|
},
|
||||||
savePageDataToStore(page, data){
|
savePageDataToStore(page, data) {
|
||||||
store.commit(storeMutations.UPDATE_PAGE_DATA, { page: page, data: data });
|
store.commit(storeMutations.UPDATE_PAGE_DATA, { page: page, data: data });
|
||||||
},
|
},
|
||||||
onSubmit() {}, // DO NOT REMOVE; needed to prevent default form submit behavior
|
onSubmit() { }, // DO NOT REMOVE; needed to prevent default form submit behavior
|
||||||
onInvalidSubmit({ values, errors, results }) {
|
onInvalidSubmit({ values, errors, results }) {
|
||||||
// identify the first error field and put focus on it
|
// identify the first error field and put focus on it
|
||||||
// get error names array
|
// get error names array
|
||||||
|
|
@ -40,6 +40,28 @@ export default {
|
||||||
el && el.focus();
|
el && el.focus();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
pushEventToGA(category, action, label, value) {
|
||||||
|
const eventToBePushed = {
|
||||||
|
'event': 'ga_event',
|
||||||
|
'category': category,
|
||||||
|
'action': action,
|
||||||
|
'label': label,
|
||||||
|
'value': value,
|
||||||
|
'path': '/fmg/' + getQueryStringValue('fmgPage')
|
||||||
|
}
|
||||||
|
pushToDataLayerIfDefined(eventToBePushed);
|
||||||
|
},
|
||||||
|
|
||||||
|
pushPageViewToGA() {
|
||||||
|
const pageViewEvent = {
|
||||||
|
'event': 'logPageview',
|
||||||
|
'pagePath': '/fmg/' + getQueryStringValue('fmgPage'),
|
||||||
|
'pageTitle': getQueryStringValue('fmgPage')
|
||||||
|
};
|
||||||
|
pushToDataLayerIfDefined(pageViewEvent);
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
storeActions() {
|
storeActions() {
|
||||||
|
|
@ -65,3 +87,14 @@ 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue