mirror of
https://github.com/digitalocean/nginxconfig.io
synced 2024-11-10 12:34:12 +00:00
Try sending directly to the analytics tracker?
This commit is contained in:
parent
2dce7a956f
commit
989d2b257d
1 changed files with 32 additions and 12 deletions
|
@ -26,18 +26,9 @@ THE SOFTWARE.
|
|||
|
||||
export default (action, category, label, value, nonInteraction = false) => {
|
||||
try {
|
||||
// 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', {
|
||||
const tracker = window.ga.getAll()[0];
|
||||
if (tracker) {
|
||||
tracker.send({
|
||||
hitType: 'event',
|
||||
eventCategory: category,
|
||||
eventAction: action,
|
||||
|
@ -49,4 +40,33 @@ export default (action, category, label, value, nonInteraction = false) => {
|
|||
} catch (_) {
|
||||
// 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 a new issue