GA event methods
This commit is contained in:
parent
ec47baea6f
commit
80ef6b85dd
1 changed files with 37 additions and 4 deletions
|
|
@ -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