项目作者: greenstick

项目描述 :
A Simple Website User Interaction Tracker.
高级语言: JavaScript
项目地址: git://github.com/greenstick/interactor.git
创建时间: 2015-08-05T19:07:31Z
项目社区:https://github.com/greenstick/interactor

开源协议:BSD 2-Clause "Simplified" License

下载


Interactor.js

A simple, light-weight (< 5KB minified), no dependency, front-end website interaction tracker for personal websites and web projects.

Collects usage data and send it to a user-defined server endpoint on the beforeunload event.

Great for creating a database to drive analytics, inform A/B testing, monitor engagement, and guide site optimization decisions.

This data can help you analyze:

  • How your users navigate your website
  • Engagement levels on a per-page and site-wide basis
  • What platforms, language settings, and browser dimensions your users have
  • Bounce rates, page and site bottle-necks, impressions, and conversions

DOI

Documentation

Documentation is currently being written. There’s a working (front-end) example of Interactor. To explore it, open up your browsers’ console and click on the interaction and conversion buttons.

Interactor currently supports modern browsers: Chrome, Firefox, & Safari. Additional testing & input is welcome.

What Data is Provided?

General Data:

  • Which page is loaded
  • When the user loaded the page
  • When the user left the page
  • The URL of the loaded page
  • The previous page location
  • The title of the page
  • The language settings of the user
  • The user’s platform
  • The port used to access the web server
  • The inner and outer width and height of the web browser

Interaction / Conversion Data:

  • The interaction type (i.e. general interaction or conversion)
  • The time of the interaction
  • The event that triggered interaction
  • The target HTML element tag
  • The target HTML element classes
  • The target HTML element content (i.e. text, etc.)
  • The cursor position relative to client
  • The cursor position relative to screen

Example Usage

Include the script in your HTML and invoke it.

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Interaction Tracker Example</title>
  5. </head>
  6. <body>
  7. <div class="interaction"></div>
  8. <div class="interaction"></div>
  9. <div class="interaction"></div>
  10. <div class="conversion"></div>
  11. <script src="interactor.min.js" type="application/javascript"></script>
  12. <script>
  13. // An example instantiation with custom arguments
  14. var interactions = new Interactor({
  15. interactions : true,
  16. interactionElement : "interaction",
  17. interactionEvents : ["mousedown", "mouseup", "touchstart", "touchend"],
  18. conversions : true,
  19. conversionElement : "conversion",
  20. conversionEvents : ["mouseup", "touchend"],
  21. endpoint : '/usage/interactions',
  22. async : true,
  23. debug : false
  24. });
  25. </script>
  26. </body>
  27. </html>

To track a users interactions with an element, simply add the .interaction CSS class to the element.

Have a conversion point on your page? You can add that too, just add the .conversion CSS class to your conversion’s HTML element.

Want to track a user’s interactions and/or conversions with different element classes already on your page? Create multiple instances and allow each to target a specific element to track. No update to your HTML neccessary.

Example:

  1. var elementsToTrack = [
  2. {
  3. element: "element1",
  4. events : ["mouseup", "touchend"]
  5. },
  6. {
  7. element: "element2",
  8. events : ["mouseup"]
  9. },
  10. {
  11. element: "element3",
  12. events : ["mouseup"]
  13. }
  14. ];
  15. for (var i = 0; i < elementsToTrack.length; i++) {
  16. var e = elementsToTrack[i];
  17. new Interactor({
  18. interactionElement : e.element,
  19. interactionEvents : e.events
  20. });
  21. }

Default Parameters:

  1. {
  2. interactions : true,
  3. interactionElement : 'interaction',
  4. interactionEvents : ['mouseup', 'touchend'],
  5. conversions : false,
  6. conversionElement : 'conversion',
  7. conversionEvents : ['mouseup', 'touchend'],
  8. endpoint : '/interactions',
  9. async : true,
  10. debug : true
  11. }

Can I Buy You a Coffee?

Sure! I’m a grad student – coffee is always very much appreciated! Thanks!

Buy me a coffee