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>
) => {
// GA3
ga?.("send", "event", event, action);
if (window.ga) {
window.ga("send", "event", event, action);
}
// GA4
window.dataLayer?.push({
event,
action,
...metadata,
});
if (window.dataLayer) {
window.dataLayer.push({
event,
action,
...metadata,
});
}
};
}