Skip to content
/ purser Public
forked from bilbof/purser

A lightweight JavaScript library for preserving user data from first website visit to signup.

Notifications You must be signed in to change notification settings

hhy5277/purser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Purser

A lightweight JavaScript library for preserving user data from first website visit to signup.

Usage

The library stores data such as utm_medium, landing_page and referrer in a localStorage object, and makes the object available via a handy API with the following methods:

Purser.create() // automatically called on first website visit
Purser.fetch() // returns the object
Purser.convert(obj) // returns the object updated with conversion data
Purser.update(obj) // lets you add additional parameters to the object
Purser.destroy // removes the object from localStorage

View a live example at http://purser.herokuapp.com/.

Installation

git clone https://github.com/bilbof/purser
  1. Add purser.js to every page on your website. When a visitor creates an account, call purser.convert(obj) and add the user to your CRM/ChartMogul with attributes returned.
  2. When a visitor creates an account, call purser.convert(obj) to get the visitor's marketing attributes
  3. Add the user's marketing attributes to them in your CRM or app

Example

See an example at http://github.com/bilbof/purser/example.

Code example

<script src="purser.js"></script>
<script>
  $('.red-signup-button').click(function(){

      var attributes = purser.convert({
        signup_button: "red-signup-button"
      });

      // here send the customer object to your CRM/app with their attributes
  });
</script>

The attributes object in the example above would look something like this:

{
	"first_website_visit": "2017-02-19T17:52:18.088Z",
	"referrer": "www.google.co.uk",
	"browser_timezone": 0,
	"browser_language": "en-GB",
	"landing_page": "http://localhost:5000/product",
	"screen_height": 800,
	"screen_width": 1280,
	"utm_medium": "google_search_ads",
	"utm_source": "google",
	"signup_button": "red-signup-button",
	"converted_at": "2017-02-19T17:52:41.981Z",
	"conversion_page": "http://localhost:5000/signup"
}

About

A lightweight JavaScript library for preserving user data from first website visit to signup.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 68.9%
  • HTML 30.0%
  • CSS 1.1%