Package Exports
- @technoapple/ga4
- @technoapple/ga4/build/main/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@technoapple/ga4) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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/ga4Basic 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