Analytics for global reset/remove

This commit is contained in:
MattIPv4
2020-07-14 16:41:55 +01:00
parent da9fddac06
commit a9cb3e54f6
2 changed files with 51 additions and 26 deletions

View File

@@ -25,30 +25,27 @@ THE SOFTWARE.
*/
export default (action, category, label, value) => {
console.log({
eventCategory: category,
eventAction: action,
eventLabel: label,
eventValue: value,
});
try {
// gtag.js
if (window.gtag) {
return window.gtag('event', action, {
event_category: category,
event_label: label,
value,
});
}
// gtag.js
if (window.gtag) {
return window.gtag('event', action, {
event_category: category,
event_label: label,
value,
});
}
// analytics.js
if (window.ga) {
return window.ga('send', {
hitType: 'event',
eventCategory: category,
eventAction: action,
eventLabel: label,
eventValue: value,
});
// analytics.js
if (window.ga) {
return window.ga('send', {
hitType: 'event',
eventCategory: category,
eventAction: action,
eventLabel: label,
eventValue: value,
});
}
} catch (_) {
// If analytics fail, don't block anything else
}
};