1.0.1 • Published 1 year ago

google-standard-events v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Google standard events

This is a simple types-only library about the Google-recommended events for ecommerce, as referenced here.

Usage

// With Tag Manager
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
  });
};
// With Google tag
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);
};
1.0.1

1 year ago

1.0.0

1 year ago