Giter Club home page Giter Club logo

gasp.js's Introduction

gasp.js

With just one line of javascript code, you can track your site with Google Analytics. Simple and easy. Just insert attributes into html. GASP - Google Analytics for Single Page (or One Page)


Version

  • v0.1.0

Why use "gasp.js"?

  • Pageviews are sent automatically;
  • Event occurrences are sent according to the attributes entered in the html file;
  • Scrolling height change occurrences are automatically sent as events (in percentage and quadrant);

Installation

  1. include the javascript code on your page: <script src="gasp.js"></script>

  2. initialize GASP: new GASP({ UA: "UA-XXXXX-Y"});

    Options

    Attributes Options Default Description
    UA string UA-XXXXX-Y Your Google Analytics tracking code
    debug boolean false Enables logging in the browser console
    sendPageViewByHash boolean true Send a pageview when there is a hash change in the current url
    sendHitMaxScrollHeight boolean true Send scroll height occurrences as events, when the user exits the page (in percentage and quadrant)

    Example: new GASP({ UA: "UA-XXXXX-Y", debug: true, sendPageViewByHash: true, sendHitMaxScrollHeight: true });


Event Tracking

Simply enter the attributes "gasp-category", "gasp-action" and "gasp-label" in your html.

\o/

-> Informing the event fields: category, action and label

<ul class="menu">
	<li>
		<a href="#home" gasp-category="header" gasp-action="menu" gasp-label="Home">
			Home
		</a>
	</li>
	<li>
		<a href="#contact" gasp-category="header" gasp-action="contact" gasp-label="Contact">
			Contact
		</a>
	</li>
</ul>

-> No need to repeat "category"

<ul class="menu" gasp-parent-category="header">
	<li>
		<a href="#home" gasp-action="menu" gasp-label="Home">
			Home
		</a>
	</li>
	<li>
		<a href="#contact" gasp-action="contact" gasp-label="Contact">
			Contact
		</a>
	</li>
</ul>

-> "Label" is automatically the value of the tag

<div class="navbar" gasp-parent-category="header">
	    <ul class="menu">
			<li>
				<a href="#home" gasp-action="menu" gasp-label="*">
					Home
				</a>
			</li>
			<li>
				<a href="#contact" gasp-action="contact" gasp-label="*">
					Contact
				</a>
			</li>
		</ul>
</div>

Page Tracking

Sends automatically a pageview hit to Google Analytics when there is a change in the hash of the URL.

For example:

  • /index
  • /index#about
  • /index#contact

For this it is necessary that "sendPageViewByHash" is true (default: true).


Scroll Tracking

Event with the maximum percentage and quadrant of the screen preview.

  • Percentage: up to 100%;
  • Quadrant: up to 4;

Example: If user rolled halfway through the screen:

  • Category: GASP.maxScroll
  • Action:quadrant2
  • Label:50

Example: if user rolled up 3/4 screen:

  • Category: GASP.maxScroll
  • Action:quadrant3
  • Label:75

For this it is necessary that "sendHitMaxScrollHeight" is true (default: true).


Questions? Need help?

[email protected]

gasp.js's People

Contributors

fernandofc avatar

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.