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

@data-visuals/analytics

v0.1.1

Published

Consistently track how pages perform the Texas Tribune Data Visuals way.

Downloads

2

Readme

Data Visuals Analytics

An easy way to hook up Google Analytics (and any future trackers!) in Data Visuals projects.

Installation

npm install @data-visuals/analytics

Usage

Two of autotrack's plugins are included in this library — cleanUrlTracker and eventTracker. cleanUrlTracker is already pre-configured and requires no extra work, but eventTracker only enables what's detailed in the documentation for that plugin and will require extra tagging in your HTML.

This library does not load the Google Analytics library for you. You'll still need to ensure that makes it on the page. However, @data-visuals/analytics expects that to happen asynchronously so it can be loaded at any time.

In your HTML (either right before your <body> element closes, or at the bottom of the <head>), load the Google Analytics library.

<!-- Google Analytics -->
<script async src="https://www.google-analytics.com/analytics.js"></script>
<!-- End Google Analytics -->

The library exports an init() function to be called. It's recommended that you use Webpack's code splitting functionality (if your environment supports it) to load this library so nothing is blocked by its loading.

import(/* webpackChunkName: "analytics" */ '@data-visuals/analytics').then(
  analytics => analytics.init()
);

If for some reason you don't want to do that, or you're using this somewhere that isn't allowed, importing it and calling it normally will also work.

import { init } from '@data-visuals/analytics';

init();

API

init

Initializes all the analytics setup. Creates trackers and sets initial values on the trackers.

Parameters

  • options Object (optional, default {})
    • options.linkerDomains Array<String> List of domains to pass to linker plugin (optional, default DEFAULT_LINKER_DOMAINS)
    • options.trackingId String Google Analytics tracking ID (optional, default DEFAULT_TRACKING_ID)

Examples

// Async method
import('@data-visuals/analytics').then(analytics => analytics.init());

// Standard import method
import { init } from '@data-visuals/analytics';

init();

Returns void

License

MIT