Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@docusaurus/plugin-google-gtag

Package Overview
Dependencies
Maintainers
4
Versions
1819
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@docusaurus/plugin-google-gtag

Global Site Tag (gtag.js) plugin for Docusaurus.

  • 0.0.0-6116
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
278K
decreased by-12.62%
Maintainers
4
Weekly downloads
 
Created

What is @docusaurus/plugin-google-gtag?

@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.

What are @docusaurus/plugin-google-gtag's main functionalities?

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;

Other packages similar to @docusaurus/plugin-google-gtag

FAQs

Package last updated on 23 Oct 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc