• Stars
    star
    1,128
  • Rank 41,247 (Top 0.9 %)
  • Language
    JavaScript
  • License
    ISC License
  • Created almost 8 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Examples and best practices for using analytics.js

analytics.js boilerplate

Best practices for implementing analytics.js on modern websites.

For an in-depth explanation of all the features used in this boilerplate (as well as how to report on them), see my article:

The Google Analytics Setup I Use on Every Site I Build →

Boilerplate versions

analytics/base.js

The base boilerplate extends the default tracking snippet and includes the following features:

  • Tracks uncaught errors.
  • Tracks custom user, session, and hit-level dimensions.
  • Sends an initial pageview.
  • Sends a pageload performance event.

analytics/autotrack.js

The autotrack boilerplate builds on top the base boilerplate and includes select autotrack plugins

analytics/multiple-trackers.js

The multiple-trackers boilerplate builds on the autotrack boilerplate and includes support for using multiple trackers.

Running the boilerplate locally

analytics.js boilerplate uses webpack to compile the source and webpack-dev-server to run it locally.

To install the dependencies and load the boilerplate in a browser, run the following commands:

npm install
npm start

Then visit localhost:8080 in your browser and open the developer console to see the analytics.js debug output.

Running different boilerplate versions

The boilerplate index.js JavaScript file imports the base boilerplate by default. To run a different version, replace the URL imported via import('./analytics/base.js') with the version you want to load.

More Repositories

1

flexbugs

A community-curated list of flexbox issues and cross-browser workarounds for them.
13,629
star
2

solved-by-flexbox

A showcase of problems once hard or impossible to solve with CSS alone, now made trivially easy with Flexbox.
CSS
13,009
star
3

html-inspector

HTML Inspector is a code quality tool to help you and your team write better markup. It's written in JavaScript and runs in the browser, so testing your HTML has never been easier.
JavaScript
2,317
star
4

responsive-components

A modern approach to styling elements based on the size of their container
JavaScript
586
star
5

webpack-esnext-boilerplate

JavaScript
513
star
6

polyfill

A library to make creating CSS polyfills much easier.
JavaScript
296
star
7

rollup-native-modules-boilerplate

A demo app showcasing the use of real JavaScript modules in production—complete with cross-browser fallbacks for legacy browsers.
JavaScript
223
star
8

blog

The source code for https://philipwalton.com
JavaScript
183
star
9

private-parts

A simple and intuitive way to shim private methods and properties in JavaScript.
JavaScript
107
star
10

mozart

A full-featured, classical inheritance library for Node.js and the browser.
JavaScript
84
star
11

easy-sauce

Easily run JavaScript unit tests on the Sauce Labs cloud.
JavaScript
74
star
12

talks

HTML
46
star
13

dom-utils

A small, modular DOM utility library
JavaScript
39
star
14

import-maps-caching-demos

Demos showing how to use Import Maps to prevent cascading cache invalidations
JavaScript
22
star
15

selectable

Easily get and set the text selection with an HTML element.
JavaScript
16
star
16

router

A simple router that binds URLs paths and patterns to functions.
JavaScript
9
star
17

shimr

A proof-of-concept for building CSS polyfills
JavaScript
8
star
18

rollup-built-in-modules

A demo of using rollup with built-in modules
JavaScript
8
star
19

ingen

JavaScript
7
star
20

google-analytics-browser-stats

JavaScript
6
star
21

dotfiles

OS X dotfiles, config, bash, git, etc.
Vim Script
6
star
22

dev

HTML
5
star
23

deep-watch

Exactly like fs.watch, but with sub-directory support.
JavaScript
5
star
24

slide-deck

HTML
4
star
25

deeplinker

JavaScript
4
star
26

handbrake

JavaScript
4
star
27

usage-trends

JavaScript
4
star
28

navigation-event-proposal

3
star
29

solarized-dark-minimalist-syntax

CSS
3
star
30

github-stars

JavaScript
2
star
31

rollup-3245-repro

JavaScript
2
star
32

yore

Async and error handling sugar on top of the HTML5 History api.
JavaScript
2
star
33

photo-validator

JavaScript
2
star
34

philipwalton.github.io

GitHub pages root
HTML
1
star