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

ga-localstorage

v1.0.2

Published

Google's Universal Analytics async snippet using HTML5 `localStorage` instead of HTTP cookies.

Downloads

7

Readme

Google Analytics LocalStorage

A JavaScript Google Universal Analytics snippet that uses localStorage, when available, instead of HTML cookies.

Do it for the bytes.

The LocalStorage option is now officially supported by Google.

Important Caveats. Read these.

  • You cannot do cross-domain tracking of a user. You will not be able to track the same user on both http://www.example.com and http://example.com. A single user visiting both of these will result in two unique users.
  • You cannot do cross-scheme tracking of a user. You will not be able to track the same user on both https://www.example.com and http://www.example.com. A single user visiting both of these will result in two unique users.
  • You might not be able to utilize some of the advanced Google Analytics features.

You should only use this script if all of the following are true:

  • the site you are tracking doesn't track users on other subdomains.

  • the site you are tracking is always served over https or always over http, never both/either.

  • you pretty much just track page views, users, and/or events (since that is all I've tested myself).

Another thing to note: this script changes the global ga function to ct. If you call ga in your scripts to track events, make sure you update all your ga() calls to ct() calls!

Documentation

Did you read the Important Caveats? Make sure you do that before you read any more.

Copy+Paste

  1. Copy the code in ga-localstorage.js into your project's template file.
  2. Replace UA-XXXXXXXX-X with your TrackingID.

npm

  1. Install node and npm (if you don't know what these are, or don't have these installed already, you should probably follow the Copy+Paste section above).
  2. Install the ga-localstorage package (optionally saving it to your package.json): - npm install ga-localstorage --save
  3. Build your Google Analytics JavaScript snippet: - var analyticsSnippet = require("ga-localstorage")("UA-8675309-1");
  4. Do whatever you want with it. - you should probably output it between a <script> and a </script> right before </body>.

History

Read Google Async Analytics using LocalStorage for the back story.

Read Use localStorage for Google Analytics tracking when available #1444 for more fun HTML5 Boilerplate.

Feedback

Give it to me here and at @pxcoach.