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

  • 2.0.0-alpha.50
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
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 02 Apr 2020

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