electron-ga-uuid
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.1 • Public • Published

    electron-ga-uuid

    Google Analytics client for Electron applications with some useful built in features.

    Forked from electron-ga. Changed to use a locally stored unique id, which can be reset if requested.

    Features

    Easy to start using

    First create a Web Property in Google Analytics and add a Mobile App View. The Mobile App View is better suited to display analytics from Electron, including application version.

    electron-ga-uuid works only in the renderer process.

    import Analytics from 'electron-ga-uuid';
     
    const analytics = new Analytics('UA-XXXXXXXX-X');

    Then:

    await analytics.send('screenview', { cd: 'User List' });
    await analytics.send('event', { ec: 'Scroll', ea: 'scrollto', el: 'row', ev: 123 });

    electron-ga-uuid uses Google Analytics Measurement Protocol. You can add custom parameters or override any of them.

    API Reference

    constructor(trackId[, initParams])

    The trackId is a string and its format is: UA-XXXXXXXX-X.

    The initParams is an object and its optional properties are:

    • protocolVersion
    • trackId
    • clientId
    • userId - undefined by default
    • appName
    • appVersion
    • language
    • userAgent
    • viewport
    • screenResolution

    You can set any of them with a constant string value or a getter function, that returns a string value:

    const analytics = new Analytics('UA-XXXXXXXX-X', {
      userId: '123456',
      language: () => store.getState().language
    });

    send(hitType[, additionalParams]) -> Promise

    The hitType is a string. You can find here the available values.

    The additionalParams is an object with any properties, which are acceptable by the Google Analytics Measurement Protocol.

    resetClientId()

    Reset the Client Id if the user requests

    import { resetClientId } from 'electron-ga-uuid';
    resetClientId();

    License

    MIT

    Developed by

    JayStack

    Install

    npm i electron-ga-uuid

    DownloadsWeekly Downloads

    6

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    22.8 kB

    Total Files

    18

    Last publish

    Collaborators

    • avatar