You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

inject-ga

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inject-ga

Inject Google Analytics tracking code in HTML pages.

0.2.0
Source
npmnpm
Version published
Weekly downloads
3
-76.92%
Maintainers
1
Weekly downloads
 
Created
Source

Inject Google Analytics tracking code in HTML pages.

Installation:

npm install inject-ga

Usage:

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 <head> tag.

Input:

<html>
<body>
  <i>am</i>
</body>
</html>

Output:

<html>
<body>
  <i>am</i>
  <script>
  !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');
  </script>
</body>
</html>

Keywords

snippet

FAQs

Package last updated on 24 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts