fix: ga is not defined

This commit is contained in:
Tom Moor
2023-02-14 00:00:41 -05:00
parent 0976e85a1a
commit b50bee1ec7

View File

@@ -14,13 +14,17 @@ export default class Analytics {
metadata?: Record<string, string> metadata?: Record<string, string>
) => { ) => {
// GA3 // GA3
ga?.("send", "event", event, action); if (window.ga) {
window.ga("send", "event", event, action);
}
// GA4 // GA4
window.dataLayer?.push({ if (window.dataLayer) {
event, window.dataLayer.push({
action, event,
...metadata, action,
}); ...metadata,
});
}
}; };
} }