@technoapple/ga4
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

GA4

GA4 TypeScript Library to provide functions to support sending GA4 events.

Features

  • provide functions to send GA4 events.
  • helper functions to get value via window.dataLayer.

Get Started

npm i @technoapple/ga4

Basic Usage

sending GA4 events.

import { ga4 } from '@technoapple/ga4';
// init
ga4.init({
    targetId: 'g-123'
} as ga4Option);

// sending event
ga4.send('test_event', {
    'event_key_1': 1
});      

sending GA4 events by gtag.

ga4.gtag('event', 'test', {
    'test': 1
});   

get value from dataLayer.

import { dataLayerHelper } from '@technoapple/ga4';
window.dataLayer.push({
    'test': 11
});

const value = dataLayerHelper.get('test');
console.info(value); // 11

Package Sidebar

Install

npm i @technoapple/ga4

Weekly Downloads

52

Version

1.0.4

License

ISC

Unpacked Size

64.9 kB

Total Files

39

Last publish

Collaborators

  • keke78ui9