All Projects → shinnn → Isogram

shinnn / Isogram

Licence: mit
Generate Google Analytics tracking code with any isogrammic parameters you like

Programming Languages

javascript
184084 projects - #8 most used programming language
ecmascript
72 projects

Projects that are alternatives of or similar to Isogram

Openapi Cli Generator
Generate a CLI from an OpenAPI 3 specification
Stars: ✭ 121 (-69.44%)
Mutual labels:  cli, code-generator
Devdash
🍱 Highly Configurable Terminal Dashboard for Developers and Creators
Stars: ✭ 939 (+137.12%)
Mutual labels:  cli, google-analytics
Drupal Code Generator
A code generator for Drupal.
Stars: ✭ 184 (-53.54%)
Mutual labels:  cli, code-generator
Graphql Zeus
GraphQL client and GraphQL code generator with GraphQL autocomplete library generation ⚡⚡⚡ for browser,nodejs and react native
Stars: ✭ 1,043 (+163.38%)
Mutual labels:  cli, code-generator
Xcassetpacker
A command line tool for converting a folder of images into an .xcasset package for Xcode
Stars: ✭ 150 (-62.12%)
Mutual labels:  cli, code-generator
Swiftcolorgen
A tool that generate code for Swift projects, designed to improve the maintainability of UIColors
Stars: ✭ 152 (-61.62%)
Mutual labels:  cli, code-generator
Goaccess
GoAccess is a real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser.
Stars: ✭ 14,096 (+3459.6%)
Mutual labels:  cli, google-analytics
Collision
💥 Collision is a beautiful error reporting tool for command-line applications
Stars: ✭ 3,993 (+908.33%)
Mutual labels:  cli
Pipupgrade
🗽 Like yarn outdated/upgrade, but for pip. Upgrade all your pip packages and automate your Python Dependency Management.
Stars: ✭ 391 (-1.26%)
Mutual labels:  cli
Fubectl
Reduces repetitive interactions with kubectl
Stars: ✭ 370 (-6.57%)
Mutual labels:  cli
Certificationy Cli
The CLI tool to train certifications
Stars: ✭ 381 (-3.79%)
Mutual labels:  cli
Isort
A Python utility / library to sort imports.
Stars: ✭ 4,377 (+1005.3%)
Mutual labels:  cli
Ticker.sh
Real-time stock tickers from the command-line.
Stars: ✭ 392 (-1.01%)
Mutual labels:  cli
React Slate
Write interactive CLI apps with React
Stars: ✭ 385 (-2.78%)
Mutual labels:  cli
Fire Hpp
Fire for C++: Create fully functional CLIs using function signatures
Stars: ✭ 395 (-0.25%)
Mutual labels:  cli
Pantheon
An enterprise-grade Java-based, Apache 2.0 licensed Ethereum client
Stars: ✭ 383 (-3.28%)
Mutual labels:  cli
Datamodel Code Generator
Pydantic model generator for easy conversion of JSON, OpenAPI, JSON Schema, and YAML data sources.
Stars: ✭ 393 (-0.76%)
Mutual labels:  code-generator
Mri
Quickly scan for CLI flags and arguments
Stars: ✭ 394 (-0.51%)
Mutual labels:  cli
Beats
A command-line drum machine. Convert a beat notated in YAML into a *.wav file.
Stars: ✭ 389 (-1.77%)
Mutual labels:  cli
Cinf
Command line tool to view namespaces and cgroups, useful for low-level container prodding
Stars: ✭ 389 (-1.77%)
Mutual labels:  cli

isogram

npm version Build Status Coverage Status

Generate Google Analytics code with any isogrammic parameters you like

Screencast

Introduction

Story

Here is the default tracking code of Google Analytics.

(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, the index.html of HTML5 Boilerplate includes the following tracking code:

(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 amusing alteration 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 it does

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 isn't. But, I think, isogram can surprise the people seeing the source code of your website, such as Bynens's commit.

Websites using isogram

The real-life examples that uses the code isogram generates in their pages

Website (A - Z) URL Tracking code parameters
apiDoc apidocjs.com a p i d o c
BrowserSync browsersync.io s y n c I t
Chris Down's website chrisdown.name c d o w n
choosealicense.com choosealicense.com L I C e N S E
cssnext cssnext.io c s S n e x t
Dogescript dogescript.com W o w s u c h
Donavon West's blog donavon.js.org D o N a V O n
Go, muffins go! gomuffinsgo.com M U F f I N S
gulp.js gulpjs.com g u l p j s
hapi hapijs.com h a p i j s
Inktweb.nl inktweb.nl i n k t w e b
Jekyll jekyllrb.com j e k y l L
kanyewest.com kanyewest.com k a n y e
starico stari.co s t a r i c o
Tim De Pauw's website tmdpw.eu t m d p w e u
Zachary Espiritu's website zacharyespiritu.com z a c h A r y

Feel free to create a pull request to add your site here.

CLI

Installation

Use npm.

npm install --global isogram

Usage

isogram [parameters] [options]

Parameters

Default: GoOgle

[parameters] need to be a nonpattern word with no fewer than 3 and no greater than 7 characters, each of whom can be a valid JavaScript variable name.

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

Options

--id,       -i <ID>      Set web property ID
--domain,   -d <domain>  Set domain
--global,   -g <name>    Change global variable name ("ga" by default)
--double,   -w           Use double quotes (single quotes by default)
--minify,   -m           Minify output like UglifyJS
--no-color,              Print code in a single color
--color,    -c           Colorize parameters anyway (enabled by default)
--no-track,              Just load, don't send a pageview
--track,    -t           Send a pageview after loading (enabled by default)
--help,     -h           Print usage information
--version,  -v           Print version

Example

isogram YoyOjs --id 12345678-9 --domain awesome-website.com

yields:

!function(Y,o,y,O,j,s){Y.GoogleAnalyticsObject=y;Y[y]||(Y[y]=function(){
(Y[y].q=Y[y].q||[]).push(arguments)});Y[y].l=+new Date;j=o.createElement(O);
s=o.getElementsByTagName(O)[0];j.src='//www.google-analytics.com/analytics.js';
s.parentNode.insertBefore(j,s)}(window,document,'ga','script');

ga('create', 'UA-12345678-9', 'awesome-website.com');
ga('send', 'pageview');

API

You can use isogram as a JavaScript library instead of CLI.

Installation

Package managers

npm
npm install isogram

Standalone

Download the standalone build.

Usage

isogram([parameters, options])

parameters: String (3 or more and 7 or less characters)
options: Object
Return: String

It returns a string of Google Analytics JavaScript code.

// Default
isogram(); //=> '!function(G,o,O,g,l,e){G.GoogleAnalyticsObject=O,G[O]||(G[O]=function(){\n(G[O].q=G[O].q||[]).push(arguments)}),G[O].l=+new Date,l=o.createElement(g),\ne=o.getElementsByTagName(g)[0],l.src=\'//www.google-analytics.com/analytics.js\',\ne.parentNode.insertBefore(l,e)}(window,document,\'ga\',\'script\');\n\nga(\'create\', \'UA-XXXXX-X\', \'auto\');\nga(\'send\', \'pageview\');'

// Specify parameters
isogram('abcdef'); //=> '!function(a,b,c,d,e,f){a.GoogleAnalyticsObject=c,a[c]||(a[c]=function(){\n(a[c].q=a[c].q||[]).push(arguments)}),a[c].l=+new Date,e=b.createElement(d),\nf=b.getElementsByTagName(d)[0],e.src=\'//www.google-analytics.com/analytics.js\',\nf.parentNode.insertBefore(e,f)}(window,document,\'ga\',\'script\');\n\nga(\'create\', \'UA-XXXXX-X\', \'auto\');\nga(\'send\', \'pageview\');'
options.id

Type: String
Default: XXXXX-X

Set web property ID. UA- prefix maybe omitted.

isogram({id: '36461297-9'}); //=> '!function( ... , \'UA-36461297-9\', \'auto\');\nga(\'send\', \'pageview\');'

isogram({id: 'UA-36461297-9'}) === isogram({id: '36461297-9'}); //=> true
options.domain

Type: String
Default: auto

Set domain of the site.

isogram({domain: 'foo.example.com'}); //=> '!function( ... , \'foo.example.com\');\nga(\'send\', \'pageview\');'
options.globalName

Type: String
Default: ga

Change the global function name.

isogram({globalName: '__tracker'}); //=> '!function( ... ,document,\'__tracker\',\'script\');\n\n__tracker(\'create\', \'UA-XXXXX-X\', \'auto\');\n__tracker(\'send\', \'pageview\');'
options.minify

Type: Boolean
Default: false

Omit unnecessary whitespaces and newlines from the result.

options.singleQuotes

Type: Boolean
Default: true

false replaces all single quotes with double quotes.

options.color

Type: Boolean
Default: false

Colorize the parameters with ANSI escape code.

options.track

Type: Boolean
Default: true

false excludes create and send commands after the loading code.

License

Copyright (c) 2013 - 2018 Shinnosuke Watanabe

Licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].