Gathering detailed insights and metrics for ga-4-react
Gathering detailed insights and metrics for ga-4-react
Gathering detailed insights and metrics for ga-4-react
Gathering detailed insights and metrics for ga-4-react
npm install ga-4-react
84.2
Supply Chain
98.7
Quality
76
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
122 Stars
103 Commits
19 Forks
2 Watching
2 Branches
8 Contributors
Updated on 06 Feb 2024
Minified
Minified + Gzipped
HTML (67.13%)
TypeScript (22.68%)
JavaScript (6.04%)
CSS (4.15%)
Cumulative downloads
Total Downloads
Last day
-10.4%
971
Compared to previous day
Last week
-0.2%
5,706
Compared to previous week
Last month
-7.9%
24,375
Compared to previous month
Last year
-17.4%
671,929
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
project is not fuzzed
Details
Reason
security policy file not detected
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
61 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
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