Small, cacheable subset of Google Analytics JS client
JavaScript HTML
Latest commit a44957f Jun 1, 2016 Jesse Luoto Changed: Version to 1.1.0


Small, cacheable subset of Google Analytics JS client

This project is a non-official client for Google Analytics API.

Install to your project

You can install ga-lite to your project by adding the following code to the ended of your HTML <body>:

<script src="" async></script>
var galite = galite || {};
galite.UA = 'UA-XXXXXX'; // Insert your tracking code here

This includes the most recent version of ga-lite to your site and initializes the script with your own UA code.


Install the project by running:

npm install


This plugin requires Grunt Command-line interface grunt-cli

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to install and use Grunt plugins. Once you're familiar with that process, you may compile this project with this command:


Once the compilation has ended, Grunt has compiled the assets from /src folder to /dest folder.


At this point the plugin sends the GA pageview event to the Google Analytics server on page unload.



Type: String
Required: true

The UA code from your Google Analytics admin panel.


var galite = galite || {};
galite.UA = 'UA-123456';


Type: Boolean
Default: false

Sets the aip flag that advices GA to anonymize the IP address.


var galite = galite || {};
galite.UA = 'UA-XXXXXX'; // Insert your tracking code here
galite.anonymizeIp = true;

Known bugs

Since the beacon is sent on unload, this will most certainly mess up your GA's page timing (avg. time on site etc).

Also this library does not (yet) track page load times or support sending custom events.


As stated above, the library is still quite barebone. If you'd like to request a feature, please open an issue.

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.

Note: Do not add the dist/ folder files to your pull request, as the master branch should have the most up-to-date version's build files included. The new versions will be automatically fetched by jsdelivr to the CDN.


This project was born, because it is currently impossible to use Google Analytics' official JS library to track your site if you want to achieve 100/100 in Google PageSpeed Insights.

This happens, because Google Analytics' official JS library is has a cache header of the length of 2 hours. As PageSpeed Insights forces longer cache times, a custom GA library is practically the only way to achieve 100/100 points.

This project also makes it possible to:

  • Your site to load faster (as this is smaller lib than the official)
  • Be sure your site won't serve any code you can't check yourself

You can read more from the blog post that's written about the library.


The code in this project is licensed under MIT license.