npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@codemotion/electron-google-analytics

v0.0.1

Published

A library to implement Google Analytics in desktop apps.

Downloads

7

Readme

Google Analytics - Measurement Protocol API

travis-ci

The main purpose of this was to be used with Electron built apps.

Features

  • Pageview
  • Event
  • Screenview
  • Transaction
  • Social
  • Exception
  • Refund
  • Purchase
  • Checkout Steps
  • Checkout Options
  • Item
  • User Timing Tracking
  • Custom function for the rest (send)

Github Page - Docs

https://vacu.github.io/electron-google-analytics/

Getting started

Installation

npm i electron-google-analytics
  • Init

    Analytics(trackingID, { userAgent, debug, version })

    import Analytics from 'electron-google-analytics';
    const analytics = new Analytics('UA-XXXXXXXX-X');
  • Pageview

    Analytics#pageview(hostname, url, title, clientID)

    return analytics.pageview('http://example.com', '/home', 'Example')
      .then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });

    If you want to keep the session you need to specify the clientID.

  • Event

    Analytics#event(evCategory, evAction, { evLabel, evValue, clientID })

    return analytics.event('Video', 'play', { evLabel: 'holiday', evValue: 300})
      .then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
  • Screenview

    Analytics#screen(appName, appVer, appID, appInstallerID, screenName, clientID)

    return analytics.screen('test', '1.0.0', 'com.app.test', 'com.app.installer', 'Test')
      .then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
  • Transaction

    Analytics#transaction(trnID, { trnAffil, trnRev, trnShip, trnTax, currCode } = {}, clientID)

    return analytics.transaction(123).then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
  • Social

    Analytics#social(socialAction, socialNetwork, socialTarget, clientID)

    return analytics.social('like', 'facebook', 'home').then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
  • Exception

    Analytics#exception(exDesc, exFatal, clientID)

    return analytics.exception('IOException', 1).then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
  • Refund

    Analytics#refund(trnID, evCategory = 'Ecommerce', evAction = 'Refund', nonInteraction = 1, { prdID, prdQty } = {}, clientID)

    return analytics.refund('T123').then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
  • Purchase

    Analytics#purchase(hostname, url, title, transactionID, { trnAffil, trnRev, trnTax, trnShip, trnCoupon, prdID, prdName, prdCtg, prdBrand, prdVar, prdPos } = {}, clientID)

    return analytics.purchase('http://example.com', '/test', 'Test', 'T123', { prdID: 'P123' }).then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
  • Checkout Steps

    Analytics#checkout(hostname, url, title, checkoutStep, checkoutOpt, { prdID, prdName, prdCtg, prdBrand, prdVar, prdPrice, prdQty } = {}, clientID)

    return analytics.checkout('http://example.com', '/test', 'Test', '1', 'Visa').then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
  • Checkout Options

    Analytics#checkoutOpt(evCategory, evAction, checkoutStep, checkoutOpt, clientID)

    return analytics.checkoutOpt('Checkout', 'Option', '2', 'FedEx').then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
  • Item

    Analytics#item(trnID, itemName, { itemPrice, itemQty, itemSku, itemVariation, currCode } = {}, clientID)

    return analytics.item(123, 'Test item').then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
  • User Timing Tracking

    Analytics#timingTrk(timingCtg, timingVar, timingTime, { timingLbl, dns, pageDownTime, redirTime, tcpConnTime, serverResTime } = {}, clientID)

    return analytics.timingTrk('Category', 'jsonLoader').then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });
  • Send (for everything else for now)

    Analytics#send(hitType, params, clientID)

    return analytics.send('social', { sa: 'social', sn: 'facebook', st: 'home' })
      .then((response) => {
        return response;
      }).catch((err) => {
        return err;
      });

es5 usage

If you are not using tools like babel to use es6 with your application, you'll have to modify your code slightly. Below is an example of a test screen view that you can use out of the box with node.js

const Analytics  = require('electron-google-analytics');
const analytics = new Analytics.default('UA-XXXXXXXX-X');

function test(){
    return analytics.screen('test', '1.0.0', 'com.app.test', 'com.app.installer', 'Test')
  .then((response) => {
    return response;
  }).catch((err) => {
    return err;
  });
}
test();

Tests

cross-env TRACKING_ID='UA-XXXXXXXX-X' npm test

paypal

MIT