Giter Club home page Giter Club logo

trackomatic's Introduction

track-o-matic-logo

Trackomatic: A high-performance tracking enhancement for Google Analytics.

About

Trackomatic is a high-performance tracking enhancement for Google Analytics. It standardizes common tracking setups and saves setup time.

Note: Trackomatic.js is only compatible with Universal Analytics (analytics.js), not the older asynchronous Google Analytics (ga.js).

Documentation

http://code.viget.com/trackomatic

Usage

NOTE It is highly recommended to use the minified version for production usage.

Trackomatic is published to S3 and served by CloudFront. Urls are scoped by version. You may reference either the unpacked or minified lib based on need. Always used the minified file in production.

https://d1lmnvs8gamzin.cloudfront.net/1.1.1/trackomatic.dev.js https://d1lmnvs8gamzin.cloudfront.net/1.1.1/trackomatic.min.js

Additionally, if you are less concerned with changes in reporting or feature-set then you may reference the latest version using the following url.

https://d1lmnvs8gamzin.cloudfront.net/latest/trackomatic.dev.js https://d1lmnvs8gamzin.cloudfront.net/latest/trackomatic.min.js

Installation

To use Trackomatic, simply load trackomatic.js on your site and configure it as a plugin in your existing Google Analytics snippet. If you have installed GA through Google Tag Manager, you'll have to set a custom field.

ga('create', 'UA-XXXXX-Y', 'auto');
ga('require', 'trackomatic');
ga('send', 'pageview');

Tracked Events

  • JS errors: when an on-page script throws an error, we send some basic diagnostic information back to GA.
  • Viewport size: GA already tracks screen resolutions, but many people size their browser to only take up part of their screen, which can impact how we display content. Trackomatic fires an event when the page loads with details of viewport size and ratio.
  • Viewport resize: when a visitor resizes their browser, Trackomatic fires an event with additional details.
  • Generic click tracking: clicks on files, outbound links, email links, and telephone links.
  • First input method: after filtering out inputs used for scrolling, what is the first input type used on a webpage?

Configuration

Trackomatic accepts parameters to customize its tracking. Configuration parameters are passed as a configuration object when you initialize a plugin instance.

// with trackomatic script included in the page...

ga('create', 'UA-XXXXX-Y', 'auto');
ga('require', 'trackomatic', {
    files: ['.pdf', '.docx', '.pptx'], 
    networks: 'reddit.com', 
    redirectDelay: 100
});

ga('send', 'pageview');

Configuration Options:

debug: true || false, if true then replaces calls to tracker.send(GA) and dataLayer.push(GTM) with console.log statements. Only applies when the unminified library is included.

delimiter: Default: |. Used to parse values in data-trackomatic attributes to separate out Category, Action and Label for reporting.

prefix: default: "Trackomatic". All events reported to GA / GTM will be prefixed with this string followed by a hyphen. (e.g. Trackomatic - First Input)

redirectDelay: to make sure our tracking data reaches Google’s servers before a page reloads, Trackomatic adds in a small delay before loading the new page. By default, this delay is 100 milliseconds. You can make it longer or shorter if you prefer. Warning: setting this value too low risks potential loss of tracking data.

files: takes a single string or array of string file extensions to check against, and will fire an event on click. If no files are specified, Trackomatic will check for .pdf files only.

networks: takes a single string or array of string social media network URLs, and fires an event on click. If no networks are specified, Trackomatic will track the following networks:

  • Facebook
  • Twitter
  • Instagram
  • LinkedIn
  • Pinterest
  • Tumblr
  • Google Plus

Note: Error Reporting

A service such as Sentry or AirBrake will give the best results. Trackomatic does track JavaScript errors via proxying window.onerror which has known drawbacks.

Public API

Trackomatic.js makes certain internal utility functions public by way of the global trackomatic object. The following functions are available under trackomatic.util:

  • capitalize
  • createAnchor
  • createCookie
  • createNavigationHandler
  • debounce
  • getHost
  • getLink
  • getPathname
  • getViewportSize
  • keyCode
  • readCookie
  • getURLParams
  • roundXtoY
  • slugify

Development

In order to set up and contribute to this project you'll need to configure a few things first.

To begin, make sure you have Ruby installed.

Then run the install script:

$ ./bin/install

This will handle the installation and configuration of the following:

  • NVM/Node/NPM
  • Node Dependencies
  • Gems

Note: The build script for Trackomatic automatically generates a folder inside public with the version number specified in package.json. When preparing a new version for release, ensure you have bumped the version accordingly using npm version <major | minor | patch>.

Releases

The release process for Trackomatic has several steps:

  1. Generate documentation (using Esdoc)
  2. Deploy documentation to gh-pages (using git-directory-deploy)
  3. Compile Trackomatic from source (dev & prod versions)
  4. Sync the compiled files to S3

In order to deploy Trackomatic to S3, you'll need to setup a few environment variables. Run the following command from the root of the project:

$ cp .env.example .env

Then open .env and fill in the missing variables. The following are required in order to deploy to S3.

AWS_S3_BUCKET=< name of S3 bucket >
AWS_ACCESS_KEY_ID=< aws access key id >
AWS_SECRET_ACCESS_KEY=< aws access key secret >

The following are required in order to upload documentation to GitHub.

GIT_DEPLOY_DIR=docs
GIT_DEPLOY_BRANCH=gh-pages
GIT_DEPLOY_TOKEN=< generate using github >

By using a Private GitHub Token we obviate the need for maintainers to log in to git locally. Instead, identity is verified through the generated token.

After setting everything up, deployment is as simple as:

$ npm run release

This will run through ./bin/build creating a version directory if needed under dist as well as handle symlinking the latest directory. Finally the dist folder will be sync-ed to S3.

trackomatic's People

Contributors

averyvery avatar awavering avatar solomonhawk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

trackomatic's Issues

Add mechanism for reporting on Trackomatic usage

We want to have an idea for how people are using Trackomatic on their sites -- a simple report that contains (site, trackomatic endpoint) should help us.

This might be possible to do within S3, but we could also pass values in a tracking pixel. This should be enabled by default, but disableable in the config array.

Add option for GA Event Category Prefix

Right now, most Trackomatic event tracking is prefixed by "FED" since it was originally created for the Viget FED team. However, other teams might want to remove this, or change it to something else to distinguish it from other tracking.

Set up build process

Ideally, the many different features of trackomatic should be separated into modules (separate files) and combined using a single build step. This isn't necessarily very hard, but requires some extra steps and knowledge to set up.

Viewport Widgets

Hi, Thanks so much for the Trackomatic script.
I installed the Google Analytics Dashboard for Front-End Developers and implemented the Trackomatic script (v1.1.1) but my viewport widgets are not showing any data. Could you please let me know the widget settings for the Viewport Resize and Viewport Size widget.

Thanks,

Mitch

Add tests

Automated tests are the best way to ensure that a project like this is doing what we think it's doing, and continuing to work over time. Thankfully, once the project is broken into modules, it becomes much easier to test and shouldn't take very long to implement.

Wordpress Integration

Hello,

Any tips on the best way to use & optimize Trackomatic for use with Wordpress?

Thanks'

Measuring visibility time (in seconds)

Hi there!

Is there any way to measure and report the amount of time a DIV with a specific id/class was visible for in the viewport in total, cumulatively? ( so the div may scroll in and out of view during the entirety of the interaction) It's sort of like how long in seconds was an ad viewed for in total ..

Resolve hosting concerns

We need to hash out how/where to host this file so it's not being served from vigesharing-is-vigecaring/awavering and it's being appropriately gzipped/cached. A dev might be needed to get us up and running on something; they know more about what accounts we have access to/would be best.

Trackomatic cause not sending tracking data to GA servers

Hi guys,

I am trying to integrate trackomatic at one of my web, but when I try to add trackomatic as a GA plugin via ga('require', 'trackomatic'); it cause not sending tracking data back to GA server.

There is my test HTML content:

<!DOCTYPE html>
<html lang="cs">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <title>test</title>
  <!-- Google Analytics -->
  <script src="https://d1lmnvs8gamzin.cloudfront.net/1.1.1/trackomatic.dev.js"></script>
  <script>
    window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
    ga('create', 'UA-123456-123456', {
      'siteSpeedSampleRate': 50
    });
    ga('require', 'trackomatic', {debug: true});
    ga('require', 'linkid');
    ga('send', 'pageview');
  </script>
  <script async src='https://www.google-analytics.com/analytics.js'></script>
  <!-- /Google Analytics -->
</head>
<body></body>
</html>

Note: I am using dev version because of debugging. I know that for production should be used minified version.

The same HTML is placed on this webpage: http://test.arcao.com/trackomatic-test.html

When I comment ga('require', 'trackomatic', {debug: true}); line, the tracking data are successfully sent to GA server.

Thank you for any help.

Set up docs and releases

We should talk about how GitHub releases work, and how they interact with the Changelog. We should also probably tweak CONTRIBUTING.md so it reflects the project more specifically.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.