Socket
Socket
Sign inDemoInstall

@analytics-debugger/ga4mp

Package Overview
Dependencies
244
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @analytics-debugger/ga4mp

An Open-Source Google Analytics 4 Client-Side Protocol Implementation


Version published
Weekly downloads
120
increased by81.82%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

GA4MP - Google Analytics 4 Measurement Protocol

This is an open-source implementation for the client-side protocol used by Google Analytics 4. When I mention "client-side" is because it must be differentiated with the official GA4 Measurement Protocol offered by Google.

This library implements the public Google Analytics 4 protocol to make possible to do a full server-side tracking using NODE/JS which is not actually possible with the official Measurement Protocol , which is meant only to augment the current GA4 data and it's not ready for doing a full tracking.

Main differences with the official offerser server-side protocol are:

  • Trigger new sessions and visits starts
  • Track Sessions attribution
  • Override the User IP to populate the GEO Details
  • View the hits on the DebugView
  • Override ANY value you want
  • Easily portable to other languages

If we compare this library with the official GTAG implementation.

  • Lightweight 8.7kb (<4kb compressed ) 95.6% Lighter than a GTAG Container image
  • Privacy Compliant: Full control over which cookies are created/read and sent to Google
  • Dual Tracking (send hits to multiple measurement Ids)

Usage

ES6 Imports
import  ga4mp  from  '@analytics-debugger/ga4mp'
const  ga4track = ga4mp(["G-THYNGSTER"], {
	user_id:  undefined,
	non_personalized_ads:  true,
	debug:  true
});
Browser

<.script src="https://cdn.jsdelivr.net/npm/@analytics-debugger/ga4mp@latest/dist/ga4mp.umd.min.js">< /script>

const  ga4track  =  ga4mp(["G-THYNGSTER"],  {
	user_id: undefined,
	non_personalized_ads: true,
	debug: true
});
NODE.JS
const  ga4mp = require('./dist/ga4mp')
const  ga4track = ga4mp(["G-THYNGSTER"], {
	user_id:  undefined,
	non_personalized_ads:  true,
	debug:  true
});

More API details

Read more at: https://ga4mp.dev/

Keywords

FAQs

Last updated on 22 Jun 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc