Code Monkey home page Code Monkey logo

visitor's Introduction

Merlyn:Visitor

merlyn:visitor is forked from useful:visitor in order to make it compatible with meteor 2.4 or higher.

Simple user tracking baked into your app so you can control and manipulate the data.

Example:

Server server/lib/visitor.js

Visitor.init();

Client client/lib/visitor.js

Visitor.init({
	subscribe: true
});

Adds the packages merlyn:visitor-client and merlyn:visitor-server to your app automatically.

Installation

meteor add merlyn:visitor

What you can do

on the server

Visitor.init(options)

You must call init on the server to support anonymous user tracking.

The reason is that you have a choice of where to store the anonymous data.

options {} (all properties and the entire argument is optional)

{
	collection: your choice to name the collection
}

on the client

Visitor.init(options)

You must call init on the client to begin anonymous user tracking.

The reason is that you have a choice of where to store the anonymous data in case you want to offload this functionality to another server.

options {} (all properties and the entire argument is optional)

{
	collection: your choice to name the collection
	, connection: your choice of DDP connection to use
	, localStorageKey: your choice of what key to use to store the anonymous id in local storage
	, subscribe: true/false if you want to automatically subscribe to the current visitor's document (default **false**)
}

Visitor.id() and Meteor.visitorId()

Reactively returns the randomly generated id of the current anonymous visitor (still exists when user is logged in).

Visitor.current() and Meteor.visitor()

Reactively returns the document of the current anonymous visitor (still exists when user is logged in).

Properties that may be available on the document by default are:

{
	"_id" : "zfPeaxykvcuSSSu6f",
	"visitorId" : "2Jqa6GmSTXFWkoWX7",
	"userId" : "yQyrEySmi8mS8xgtH",
	"createdAt" : ISODate("2015-04-27T02:59:19.088Z"),
	"startPage" : "http://localhost:3000/proposal/N6gJbEvJm2dyGfMQm/send",
	"lastSeen" : ISODate("2015-04-27T03:01:12.235Z"),
	"lastSeenOnPage" : "http://localhost:3000/"
}

Why you should care

You built an app, and people are using it, nice work hot shot!

But what are your users doing?

That's really important but not always obvious. And if you're going to start tracking that yourself (because you like your data) you need a way to identify anonymous visitors.

Now you can automatically collect basic information about visitors to your app (logged in or not) and actually work with that data directly in your code, hooray!

visitor's People

Watchers

 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.