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

jquery-ga-plugin

v0.0.1

Published

A jQuery plugin wrapper around the Google Analytics ga object

Downloads

2

Readme

jquery.ga.plugin.js

This is a simple jQuery plugin wrapper around window.ga. It tries to be smart and simple to make life easier. You can pass custom properties and set custom attributes on elements if you want to be fancy. This only works with "Universal Analytics".

NOTE: If the window.ga object is not found, the plugin will automatically switch to development mode.

Usage

Basic

Setup

<button type="button">Fire An Event</button>
$('button').ga();

Results

// this is what will be called in the plugin
// you can see the default properties here
ga('send', {
  eventAction: "click",
  eventCategory: "button", // this is default, it is not pulled from the button type
  hitType: "event"
});

Development

In development mode, what would normally get passed to the ga function, gets passed to console.log.

Setup

<button type="button">Fire An Event</button>
$('button').ga({
  development: true
});

Results

// this is what will be called when development is set to true
console.log('send', {
  development: true,
  eventAction: "click",
  eventCategory: "button",
  hitType: "event"
});

Using Native Attributes

Setup

<button type="button" value="hello" name="my-label">Fire An Event</button>
$('button').ga();

Results

ga('send', {
  eventAction: "click",
  eventCategory: "button",
  eventLabel: "my-label",
  hitType: "event"
});

Using Data Attributes

Setup

<button type="button" value="1" name="submit" data-label="Data Label" data-value="10" data-category="grey-button">Fire An Event</button>
$('button').ga();

Results

ga('send', {
  eventAction: "click",
  eventCategory: "grey-button",
  eventLabel: "Data Label",
  eventValue: 10, // value is expected to be a positive int
  hitType: "event"
});

Using Different Events

Setup

<button type="button" value="hello" name="my-label">Fire An Event</button>
$('button').ga({
  eventAction: 'mouseover'
});

Results

ga('send', {
  eventAction: "mouseover",
  eventCategory: "button",
  eventLabel: "my-label",
  hitType: "event"
});

Using Different Elements And Events

Setup

<input type="text" name="search" />
$('input').ga({
  eventAction: 'input'
});

Results

// this is what is called if you click on the input and pressed the "1" key
ga('send', {
  eventAction: "input",
  eventCategory: "text",
  eventLabel: "search",
  eventValue: 1, // only positive int is passed
  hitType: "event"
});

Using Callbacks

Setup

<button type="button" value="hello" name="my-label">Fire An Event</button>
$('button').ga(function() {
  console.log('event fired');
});

Results

ga('send', {
  eventAction: "mouseover",
  eventCategory: "button",
  eventLabel: "my-label",
  hitType: "event"
});

Kitchen Sink

Setup

<button type="button">Fire An Event</button>
$('button').ga({
  eventAction: "mouseover",
  eventCategory: "button",
  eventLabel: "my-label"
}, function() {
  console.log('event fired');
});

Results

ga('send', {
  eventAction: "mouseover",
  eventCategory: "button",
  eventLabel: "my-label",
  hitType: "event"
});

More Analytics Details

Please check out the Event Tracking Web Tracking analyticsjs page.