Gathering detailed insights and metrics for @harshitpant/ga-4-react
Gathering detailed insights and metrics for @harshitpant/ga-4-react
Gathering detailed insights and metrics for @harshitpant/ga-4-react
Gathering detailed insights and metrics for @harshitpant/ga-4-react
npm install @harshitpant/ga-4-react
Typescript
Module System
Min. Node Version
Node Version
NPM Version
HTML (67.13%)
TypeScript (22.68%)
JavaScript (6.04%)
CSS (4.15%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
123 Stars
103 Commits
19 Forks
2 Watchers
2 Branches
8 Contributors
Updated on Mar 18, 2025
Latest Version
0.1.281
Package Id
@harshitpant/ga-4-react@0.1.281
Unpacked Size
102.81 kB
Size
19.92 kB
File Count
22
NPM Version
7.19.1
Node Version
14.15.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Simple wrapper of ga4 scripts for React: https://developers.google.com/analytics/devguides/collection/ga4
Example without components
1 2const ga4react = new GA4React( 3'YOUR GA CODE', 4{ /* ga custom config, optional */ }, 5[ /* additional code, optional */ ], 65000 /* timeout, optional, defaults is 5000 */, 7options /* { nonce: ['first-script-is-async','second-script'] } */ 8 9}); 10ga4react.initialize().then((ga4) => { 11 ga4.pageview('path') 12 ga4.gtag('event','pageview','path') // or your custom gtag event 13},(err) => { 14 console.error(err) 15}) 16
Example with custom components 'GA4R'
1const Test: React.FC<any> = ({ ga4 }) => { 2 return <>{ga4 && console.log(ga4)}</>; 3}; 4 5 6<GA4R code="YOUR GA CODE"> 7 <Test></Test> 8</GA4R>
console.log results:
{pageview: ƒ, gtag: ƒ, event: ƒ}
Pass pageview data to the path
prop:
1const Tracker = withTracker(props => <>{JSON.stringify(props)}</>); 2... 3 <Tracker path="myCustomPath" gaCode="GA-CODE"></Tracker> 4
1const Example = () => { 2 const ga4React = useGA4React(); // GA CODE, optional, if empty try to get from globals 3 return <>{JSON.stringify(ga4React)}</>; 4}; 5
1import React from "react"; 2import ReactDOM from "react-dom"; 3import GA4React, { useGA4React } from "ga-4-react"; 4 5const ga4react = new GA4React("G-1JXXXXX"); 6 7function MyApp() { 8 const ga = useGA4React(); 9 console.log(ga); 10 11 return <div className="App">hi!</div>; 12} 13 14(async () => { 15 await ga4react.initialize(); 16 17 ReactDOM.render( 18 <React.StrictMode> 19 <MyApp /> 20 </React.StrictMode>, 21 document.getElementById("root") 22 ); 23})();
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 5/24 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
68 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More