Socket
Socket
Sign inDemoInstall

@greenwood/plugin-google-analytics

Package Overview
Dependencies
0
Maintainers
1
Versions
134
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @greenwood/plugin-google-analytics

A Greenwood plugin adding support for Google Analytics JavaScript tracker.


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@greenwood/plugin-google-analytics

Overview

A Greenwood plugin adding support for Google Analytics JavaScript tracker. It assumes you already have your own Tracking ID(s) and can either filter out tracking for everything but your production environment so that local testing doesn't interfere with production data, or use a conditional based analyticsId using an environment variable, ex.

const analyticsId = process.env.NODE_ENV === 'xxx' ? 'UA-123...' : 'UA-345...';

For more information and complete docs about Greenwood, please visit the Greenwood website.

Installation

You can use your favorite JavaScript package manager to install this package. This package assumes you already have @greenwood/cli installed.

examples:

# npm
npm install @greenwood/plugin-google-analytics --save-dev

# yarn
yarn add @greenwood/plugin-google-analytics --dev

Usage

Use this plugin in your greenwood.config.js and pass in your Google Analytics ID, which can either be a

  • Measurement ID (recommended): ex. G-XXXXXX
  • Tracking ID (legacy): ex. UA-XXXXXX
import { greenwoodPluginGoogleAnalytics } from '@greenwood/plugin-google-analytics';

export default {
  ...

  plugins: [
    greenwoodPluginGoogleAnalytics({
      analyticsId: 'UA-XXXXXX'
    })
  ]
}

This will then add the Google Analytics JavaScript tracker snippet to your project's index.html.

Learn more about Measurement and Tracking IDs.

Options

  • analyticsId (required) - Your Google Analytics ID
  • anonymous (optional) - Sets if tracking of IPs should be done anonymously. Default is true

For links that go outside of your domain, the global function getOutboundLink is available for you to use.

Example:

<a
  target="_blank"
  rel="noopener"
  onclick="getOutboundLink('www.mylink.com');"
  href="www.mylink.com">My Link
</a>

Keywords

FAQs

Last updated on 20 Jan 2024

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc