Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@docusaurus/plugin-google-gtag
Advanced tools
Global Site Tag (gtag.js) plugin for Docusaurus.
@docusaurus/plugin-google-gtag is a plugin for Docusaurus that integrates Google Analytics (via gtag.js) into your Docusaurus site. It allows you to track page views and other events to gain insights into your site's traffic and user behavior.
Basic Setup
This feature allows you to set up the Google Analytics tracking ID and anonymize IP addresses. The tracking ID is required to link your site to your Google Analytics account.
{
"plugins": [
[
"@docusaurus/plugin-google-gtag",
{
"trackingID": "YOUR_GOOGLE_ANALYTICS_TRACKING_ID",
"anonymizeIP": true
}
]
]
}
Custom Events
This feature allows you to track custom events such as button clicks. You can use the `useGtag` hook to send custom events to Google Analytics.
{
"plugins": [
[
"@docusaurus/plugin-google-gtag",
{
"trackingID": "YOUR_GOOGLE_ANALYTICS_TRACKING_ID",
"anonymizeIP": true
}
]
]
}
// In your React component
import React from 'react';
import { useGtag } from '@docusaurus/plugin-google-gtag';
const MyComponent = () => {
const gtag = useGtag();
const handleClick = () => {
gtag('event', 'click', {
event_category: 'button',
event_label: 'my_button'
});
};
return <button onClick={handleClick}>Click me</button>;
};
export default MyComponent;
react-ga is a JavaScript module that allows you to easily add Google Analytics to your React application. It provides a simple API for tracking page views and custom events. Compared to @docusaurus/plugin-google-gtag, react-ga is more general-purpose and can be used with any React application, not just Docusaurus.
gatsby-plugin-google-gtag is a Gatsby plugin that integrates Google Analytics using gtag.js. It offers similar functionalities to @docusaurus/plugin-google-gtag but is specifically designed for Gatsby sites. It allows you to track page views and custom events in a Gatsby application.
next-google-analytics is a Next.js plugin for integrating Google Analytics using gtag.js. It provides an easy way to add Google Analytics to your Next.js application and track page views and custom events. Like @docusaurus/plugin-google-gtag, it is tailored for a specific framework, in this case, Next.js.
@docusaurus/plugin-google-gtag
Global Site Tag (gtag.js) plugin for Docusaurus.
FAQs
Global Site Tag (gtag.js) plugin for Docusaurus.
We found that @docusaurus/plugin-google-gtag demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers 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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.