New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@keg-hub/rga4

Package Overview
Dependencies
Maintainers
4
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keg-hub/rga4

React Components and hooks for integrating Google Analytics 4 into an application

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
4
Weekly downloads
 
Created
Source

RGA4

React context and hooks for integrating Google Analytics 4 into an application

Add / Install

  yarn add @keg-hub/rga4
  npm install @keg-hub/rga4

Setup

Important

  • A Google Analytic 4 Measurement ID is required
  • See this page for more information

Example

  import React, { useEffect, useCallback } from 'react'
  import { RGA4Provider, useRGA4 } from '@keg-hub/rga4'

  const Child = (props) => {

    // Use the hook to get access to the Google Analytics Context
    const rga4 = useRGA4()
    
    useEffect(() => {
      // Call the rga4.event method to send an analytics event
      rga4.event('page_view', {
        label: 'Github Readme',
        category: 'engagement',
      })
    }, [])

    // Custom analytics event when a button is clicked
    const onClick = useCallback(() => {
      // Call the rga4.event method to send an analytics event
      rga4.event('button_click', {
        event_label: 'Demo Button',
        event_category: 'engagement',
      })
    }, [ rga4 ])

    return (
      <div>
        <button onClick={onClick}>
          Demo Analytics Event
        </button>
      </div>
    )
  }

  export const Component = (props) => {
    const measurementID = `Replace with your GA4 Measurement ID`
    
    return (
      <RGA4Provider
        code={measurementID}
        config={{ ...Optional gtag config object }}
        gaCodes={[ ...Optional extra analytics IDs ]}
      >
        <Child />
      </RGA4Provider>
    )
  }

Keywords

FAQs

Package last updated on 12 Jan 2021

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