Adds Google Analytics code into HTML files.
Package | gulp-ga |
Description | Insert Google Analytics code into HTML with Gulp (gulpjs.com) |
Node Version | >= 0.9 |
Gulp Version | 3.x |
$ npm install gulp-ga --save-dev
var gulp = require('gulp');
var ga = require('gulp-ga');
// Basic usage:
gulp.task('ga', function(){
gulp.src('./index.html')
.pipe(ga({url: 'mydomain.com', uid: 'UA-12345678-1'}))
.pipe(gulp.dest('./'));
});
The page you want analysis (required)
Type: `String`
Example:
.pipe(ga({url: 'mydomain.com'})
Set the uid (required)
Type: `String`
Example:
.pipe(ga({uid: 'UA-12345678-1'}))
Set the require field (optional)
Type: `String`
Example:
.pipe(ga({require: 'urlChangeTracker'}))
Set a specific tag to insert before it.
Type: `String`
Default: `head`
Example:
.pipe(ga({tag: 'head'}))
.pipe(ga({tag: 'body'}))
Allow requests IP address anonymization
Type: `Boolean`
Default: `true`
Example:
.pipe(ga({anonymizeIp: false}))
Enable display features.
Type: `Boolean`
Default: `false`
Example:
.pipe(ga({demographics: true}))
Set an enhanced link-tracking functionality.
Type: `Boolean`
Default: `false`
Example:
.pipe(ga({linkAttribution: true}))
Set a specific bounce time.
Type: `Number`
Default: `N/A`
Example:
.pipe(ga({bounceTime: 15}))
Minify GA script code (remove \n
and trailing whitespace).
Type: `Boolean`
Default: `false`
Example:
.pipe(ga({minify: true}))
Send page view option.
Type: `Boolean`
Default: `true`
Example:
.pipe(ga({sendPageView: true}))
Add a nonce attribute and a nonce template to the script tag. So that we can implement a Content Security Policy that does not allow unsafe-inline scripts to be loaded.
Type: `Boolean`
Default: `false`
Example:
.pipe(ga({nonceTag: true}))
(MIT License)
Copyright (c) 2014,2016 Zhonghai Zuo zhonghai.zuo@gmail.com zhhz
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.