Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nobitagit/inject-ga
Inject Google Analytics tracking code in HTML pages.
https://github.com/nobitagit/inject-ga
Last synced: about 1 month ago
JSON representation
Inject Google Analytics tracking code in HTML pages.
- Host: GitHub
- URL: https://github.com/nobitagit/inject-ga
- Owner: nobitagit
- License: other
- Created: 2015-06-21T16:40:57.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-26T17:18:15.000Z (about 9 years ago)
- Last Synced: 2024-10-14T03:37:54.712Z (3 months ago)
- Language: JavaScript
- Size: 172 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Inject Google Analytics tracking code in HTML pages.
Installation:
```sh
npm install inject-ga
```Usage:
```sh
inject-ga input.html -c 'UA-66481277-1' [-o output.html] [-h]
```
Pass the `-h` flag if you want the code to be injected inside the `` tag.
If no output target is passed it will default to stdout.Input:
```htmlam
```
Output:
```htmlam
!function(G,o,O,g,l,e){G.GoogleAnalyticsObject=O;G[O]||(G[O]=function(){
(G[O].q=G[O].q||[]).push(arguments)});G[O].l=+new Date;l=o.createElement(g);
e=o.getElementsByTagName(g)[0];l.src='//www.google-analytics.com/analytics.js';
e.parentNode.insertBefore(l,e)}(window,document,'ga','script');ga('create', 'UA-66481277-1', 'auto');
ga('send', 'pageview');
```
Tests:
```sh
npm test
```