
Product
Introducing Historical Analytics – Now in Beta
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.
electron-google-analytics4
Advanced tools
https://github.com/hajeonghun/electron-google-analytics4
Installation
npm i electron-google-analytics4
or
yarn add electron-google-analytics4
Init
Analytics(trackingID, secretKey, clientID?, sessionID?)
import Analytics from 'electron-google-analytics4'; // esm
// or
const Analytics = require('electron-google-analytics4').default; // cjs
const analytics = new Analytics('G-XXXXXX', 'xxxxx-xxxxx');
Usage
To use the Analytics module, create a new instance of the Analytics class by providing the required parameters: trackingID
and secretKey
. (SecretKey Issuance Guide)
The clientID
and sessionID
parameters are optional and can be omitted if not needed.
clientID default:
machineId (node-machine-id)
sessionID default:
uuidv4 (uuid v4)
Set Single parameter (custom params)
Analytics#set(key, value)
analytics.set('user', 'jeonghun');
Remove Single parameter (custom params)
Analytics#set(key, null)
analytics.set('user', null);
Set Multiple parameter (custom params)
Analytics#setParams(obj)
const params = {name: 'hun', age: 28};
analytics.setParams(params);
Remove Multiple parameter (custom params)
Analytics#setParams()
analytics.setParams(); // customParams: {}
Set User Properties
Analytics#setUserProperties(obj)
analytics.setUserProperties({userId: 'ha', page_path: location.href});
Remove User Properties
Analytics#setUserProperties()
analytics.setUserProperties();
Send Event
Analytics#event(eventName)
analytics.event('page_view');
// Return Promise
Method chaining is available.
analytics.set('name', 'jeonghun').set('age', 28);
// or
analytics.set('name', 'jeonghun').event('page_view');
Go to analytics.google.com. click Admin, and then select Data Streams from the available options.
Click on Data Streams and select your specific data stream.
Under the Events section, click on Measurement Protocol API Secrets.
Click the Create button to generate a new API secret and assign it a nickname.
1. Log in to your GA4 account.
2. Navigate to the "Real-time" section from the left-hand menu.
3. Go to the "Overview" tab.
4. Verify if the real-time data is being displayed:
- Check if the number of active users, page views, and events are updating in real-time.
- If the data is not being displayed correctly, double-check your code and troubleshoot any issues.
FAQs
Electron GA4
The npm package electron-google-analytics4 receives a total of 721 weekly downloads. As such, electron-google-analytics4 popularity was classified as not popular.
We found that electron-google-analytics4 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.
Product
Module Reachability filters out unreachable CVEs so you can focus on vulnerabilities that actually matter to your application.
Company News
Socket is bringing best-in-class reachability analysis into the platform — cutting false positives, accelerating triage, and cementing our place as the leader in software supply chain security.