Try sending directly to the analytics tracker?
parent
2dce7a956f
commit
989d2b257d
|
@ -26,18 +26,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
export default (action, category, label, value, nonInteraction = false) => {
|
export default (action, category, label, value, nonInteraction = false) => {
|
||||||
try {
|
try {
|
||||||
// gtag.js
|
const tracker = window.ga.getAll()[0];
|
||||||
// if (window.gtag) {
|
if (tracker) {
|
||||||
// return window.gtag('event', action, {
|
tracker.send({
|
||||||
// event_category: category,
|
|
||||||
// event_label: label,
|
|
||||||
// value,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// analytics.js
|
|
||||||
if (window.ga) {
|
|
||||||
return window.ga('send', {
|
|
||||||
hitType: 'event',
|
hitType: 'event',
|
||||||
eventCategory: category,
|
eventCategory: category,
|
||||||
eventAction: action,
|
eventAction: action,
|
||||||
|
@ -49,4 +40,33 @@ export default (action, category, label, value, nonInteraction = false) => {
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// If analytics fail, don't block anything else
|
// If analytics fail, don't block anything else
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*try {
|
||||||
|
// gtag.js
|
||||||
|
if (window.gtag) {
|
||||||
|
window.gtag('event', action, {
|
||||||
|
event_category: category,
|
||||||
|
event_label: label,
|
||||||
|
value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
// If analytics fail, don't block anything else
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*try {
|
||||||
|
// analytics.js
|
||||||
|
if (window.ga) {
|
||||||
|
window.ga('send', {
|
||||||
|
hitType: 'event',
|
||||||
|
eventCategory: category,
|
||||||
|
eventAction: action,
|
||||||
|
eventLabel: label,
|
||||||
|
eventValue: value,
|
||||||
|
nonInteraction,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
// If analytics fail, don't block anything else
|
||||||
|
}*/
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue