Google standard events
This is a simple types-only library about the Google-recommended events for ecommerce, as referenced here.
Usage
import type GOOGLE_STANDARDS_EVENTS from "google-standard-events";
export const sendEvent = <E extends GOOGLE_STANDARDS_EVENTS.EVENTS>(
event: E,
ecommerce: GOOGLE_STANDARDS_EVENTS.PARAMS<E>
) => {
return dataLayer.push({
event,
ecommerce
});
};
import type GOOGLE_STANDARDS_EVENTS from "google-standard-events";
export const sendEvent = <E extends GOOGLE_STANDARDS_EVENTS.EVENTS>(
event: E,
params: GOOGLE_STANDARDS_EVENTS.PARAMS<E>
) => {
return gtag("event", event, params);
};