1.0.1 • Published 7 years ago
gulp-gtag v1.0.1
gulp-gtag
Injects Google Analytics (gtag) code into HTML files.
Information
This is a fork of gulp-ga and has been modified to support the newer gtag script for Google Analytics.
Usage
Install
$ npm install gulp-gtag --save-dev
Example
var gulp = require('gulp');
var gtag = require('gulp-gtag');
// Basic usage:
gulp.task('gtag', function(){
gulp.src('./index.html')
.pipe(gtag({uid: 'UA-12345678-1'}))
.pipe(gulp.dest('./'));
});
Options
options.uid
Set the uid (required)
Type: `String`
Example:
.pipe(gtag({uid: 'UA-12345678-1'}))
options.tag
Set a specific tag to insert before it.
Type: `String`
Default: `head`
Example:
.pipe(gtag({tag: 'head'}))
.pipe(gtag({tag: 'body'}))
options.indent
Number of spaces for indentation (for formatting)
Type: `Number`
Default: `4`
Example:
.pipe(gtag({indent: 2}))
options.minify
Minify GA script code (remove \n
and trailing whitespace).
Type: `Boolean`
Default: `false`
Example:
.pipe(gtag({minify: true}))
options.nonceTag
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(gtag({nonceTag: true}))