gulp-gtag

1.0.1 • Public • Published

gulp-gtag

Injects Google Analytics (gtag) code into HTML files.

Build Status NPM version Dependency Status

Information

This is a fork of gulp-ga and has been modified to support the newer gtag script for Google Analytics.

Packagegulp-gtag
Description Injects Google Analytics (gtag) code into HTML with Gulp (gulpjs.com)
Node Version >= 0.9
Gulp Version 3.x

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}))

LICENSE

MIT License

Package Sidebar

Install

npm i gulp-gtag

Weekly Downloads

1

Version

1.0.1

License

none

Unpacked Size

6.81 kB

Total Files

6

Last publish

Collaborators

  • hal313