Giter Site home page Giter Site logo

pixel-tracker's Introduction

pixel-tracker

A simple pixel-tracker for node.js

Build Status

Example

Collect some data with parameters, along with the defaults

var tracker = require('pixel-tracker')

tracker.use(function (error, result) {
  console.log(result)
  
  /*
  {
    "cookies": { "_tracker": "58f911166e6d31041eba8d06e11e3f77" },
    "host": "localhost:3000",
    "cache": { "max-age": "0" },
    "referer": "direct",
    "params": [],
    "decay": 1342597993859,
    "useragent": { "browser": "Chrome", "version": "20.0" },
    "language": [ "en-US", "en", { "q": "0.8" } ],
    "geo": { "ip": "127.0.0.1" },
    "domain": "localhost"
  }
  */

})

// ..

app.all('/pixel', tracker.middleware)

app.listen()

Methods

var tracker = require('pixel-tracker')

tracker.use(callback)

The callback function is called with error, result. Multiple callbacks can be used.

tracker.configure(options)

pixel-tracker has a few configurable options.

disable_cookies defaults to false maxAge defaults to 2 days, which may not be desirable based on your use case

tracker.middleware(request, response)

A function to be called for each http request which calls response.end with a 1x1 pixel for every request and then calls all the functions provided with tracker.use. This works out of the box with express and would also work with any vanilla http server as long as a cookies implementation is provided for the response object (or cookies are disabled)

var tracker = require('pixel-tracker')

tracker
  .use(function (error, result) {
    // do something with result
    // ...

  })
  .configure({ disable_cookies : true })

require('http').createServer(tracker.middleware).listen(3000)

Install

npm install pixel-tracker

Tests

npm install -g tap && npm test

License

MIT

pixel-tracker's People

Contributors

proful avatar tblobaum avatar

Watchers

 avatar  avatar

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.