2.2.2 • Published 7 months ago

zmp-ga4 v2.2.2

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

Google Analytics 4 Helper for Zalo Mini App

zmp-ga4 is a library for integrating Google Analytics 4 on Mini App. It provides an adaptive way to collect data using the default gtag.js on http(s):// protocols or Measurement Protocol on zbrowser:// protocol.

Installation

You can install zmp-ga4 using npm:

npm install zmp-ga4

Usage

To use zmp-ga4, you first need to import the AdaptiveAnalytics class and create a new instance with your Google Analytics 4 property ID and measurement ID:

import { AdaptiveAnalytics } from "zmp-ga4";

export const ga4 = new AdaptiveAnalytics(
  "G-**********", // measurement id
  "**********************" //measurement protocol api secrets
);

A config object could also be passed to the third parameter to customize tracking behavior, for example:

export const ga4 = new AdaptiveAnalytics(
  "G-**********", // measurement id
  "**********************", //measurement protocol api secrets
  {
    useMeasurementProtocolWhen() {
      return navigator.userAgent.toLowerCase().includes("ios");
    },
    gtagConfig: {
      send_page_view: false,
    },
  }
);

You can then use the trackEvent method to send events to Google Analytics 4:

ga4.trackEvent("search", {
  search_term: value,
});

The first parameter is the name of the event, and the second parameter is an object containing any additional information you want to send with the event.

License

zmp-ga4 is released under the MIT License. See LICENSE for details.

Contributing

Contributions are welcome!

Credits

zmp-ga4 is maintained by the Zalo Mini App team. If you have any questions or issues, please file an issue on GitHub.

Disclaimer

This library is not affiliated with or endorsed by Google. Google and Google Analytics are registered trademarks of Google LLC.

1.11.2

7 months ago

1.11.1

7 months ago

2.1.2

8 months ago

2.0.3

8 months ago

2.2.0

7 months ago

2.1.1

8 months ago

2.0.2

8 months ago

2.2.2

7 months ago

2.0.4

8 months ago

2.1.0

8 months ago

2.0.1

8 months ago

2.0.0

8 months ago

1.11.0

7 months ago

1.10.1

10 months ago

1.10.0

10 months ago

1.9.1

1 year ago

1.9.0

1 year ago

1.8.0

1 year ago

1.7.3

1 year ago

1.7.2

1 year ago

1.7.1

1 year ago

1.7.0

1 year ago

1.6.3

1 year ago

1.6.2

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.0

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago