JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 49
  • Score
    100M100P100Q69285F
  • License MIT

Generates Google Analytics snippet with any 'isogrammic' parameters you like

Package Exports

  • isogram

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (isogram) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

isogram

NPM version Build Status Dependency Status devDependency Status Bitdeli Badge

Generates Google's Universal Analytics code with any isogrammic parameters you like

Screencast

Introduction

Story

Here is the default tracking code of Google's Universal Analytics. (cf. Introduction to Analytics.js)

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

It has the immediate invoked function with seven parameters i s o g r a m.

On the other hand, here is the tracking code used in the index.html of HTML5 Boilerplate.

(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;e=o.createElement(i);r=o.getElementsByTagName(i)[0];e.src='//www.google-analytics.com/analytics.js';r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));

As you can see, its parameters are b o i l e r, different from the original's. This alteration with the sense of fun is authored by Mathias Bynens, based on the way of optimization and minification he blogged.

After seeing that, I modularized Bynens's way as this program, isogram.

What is isogram?

isogram is a code generator. It enables us to change the parameters of the Google Analytics tracking code, as we like, as long as they are isogrammic.

Isn't it very useful? Indeed, it is so. But, I think, isogram can surprise the poeple seeing the source of your website, such as Bynens's commit.

Installation

Make sure you have installed Node.

CLI executable

npm install -g isogram

Programmatic use on Node

Coming soon.

Usage

Use on command line

isogram [parameters] [options]

Parameters

Default: GoOgle

[parameters] need to be a nonpattern word with 5, 6, or 7 characters, each of whom can be a valid JavaScript variable name.

For example, yummy is not valid, but YuMmy is valid.

Options

-h, --help                   output usage information
-V, --version                output the version number
-i, --id <tracking ID>       change tracking-ID
-d, --domain-name <domain>   change domain name
-m, --minify                 minify output
--no-color                   output in a single color

Example

command
isogram Company --id 12345678-9 --domain-name your-company.com
output
!function(C,o,m,p,a,n,y){C.GoogleAnalyticsObject=a,C[a]=C[a]||function(){(C[a].q=C[a].q||[]).push(arguments)},C[a].l=+new Date,n=o.createElement(m),y=o.getElementsByTagName(m)[0],n.src=p,y.parentNode.insertBefore(n,y)}(this,document,"script","//www.google-analytics.com/analytics.js","ga");

ga("create", "UA-12345678-9', 'your-company.com");
ga("send", "pageview");

License

Copyright (c) 2013 - 2014 Shinnosuke Watanabe All rights reserved.

Unless otherwise stated, all source code in this repository is licensed under the MIT license.

endorse