Track action usage
This commit is contained in:
26
app/utils/Analytics.ts
Normal file
26
app/utils/Analytics.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Helper class to track events across various analytics integrations
|
||||
*/
|
||||
export default class Analytics {
|
||||
/**
|
||||
* Send an event to Analytics
|
||||
*
|
||||
* @param event The event name
|
||||
* @param action The action name
|
||||
*/
|
||||
public static track = (
|
||||
event: string,
|
||||
action: string,
|
||||
metadata?: Record<string, string>
|
||||
) => {
|
||||
// GA3
|
||||
ga?.("send", "event", event, action);
|
||||
|
||||
// GA4
|
||||
window.dataLayer?.push({
|
||||
event,
|
||||
action,
|
||||
...metadata,
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user