
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
nextjs-google-analytics
Advanced tools
Google Analytics for Next.js, based on the official next.js example with-google-analytics.
It will only be loaded on production
environments.
npm install --save nextjs-google-analytics
Add the ``GoogleAnalyticscomponents inside the
Head` to a custom document, this will take care of including the necessary scripts:
// pages/_document.js
import Document, { Html, Head, Main, NextScript } from "next/document";
import { GoogleAnalytics } from "nextjs-google-analytics";
export default class MyDocument extends Document {
render() {
return (
<Html>
<Head>
<GoogleAnalytics gaMeasurementId={"YOUR MEASUREMENT ID"} />
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}
Call the usePageView
hook inside _app.js
:
// /pages/_app.js
import { useEffect } from 'react'
import { useRouter } from 'next/router'
import { usePageView } from "nextjs-google-analytics";
const App = ({ Component, pageProps }) => {
usePageView();
const router = useRouter()
return <Component {...pageProps} />
}
export default
You can import the event
function to track a custom event:
import { useState } from "react";
import Page from "../components/Page";
import { event } from "nextjs-google-analytics";
export function Contact() {
const [message, setMessage] = useState("");
const handleInput = (e) => {
setMessage(e.target.value);
};
const handleSubmit = (e) => {
e.preventDefault();
event({
action: "submit_form",
category: "Contact",
label: this.state.message,
});
setState("");
};
return (
<Page>
<h1>This is the Contact page</h1>
<form onSubmit={handleSubmit}>
<label>
<span>Message:</span>
<textarea onChange={handleInput} value={message} />
</label>
<button type="submit">submit</button>
</form>
</Page>
);
}
FAQs
Google Analytics for Next.js
We found that nextjs-google-analytics demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.