Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ahomu/gas
Minimal helper for Google Analytics better tracking.
https://github.com/ahomu/gas
Last synced: about 1 month ago
JSON representation
Minimal helper for Google Analytics better tracking.
- Host: GitHub
- URL: https://github.com/ahomu/gas
- Owner: ahomu
- Created: 2012-05-13T07:38:45.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-06-19T00:21:08.000Z (over 12 years ago)
- Last Synced: 2024-04-14T14:20:05.657Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 153 KB
- Stars: 10
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#gas.js - Google Analytics Shorthands
"gas.js" given html driven tracking support.
**this is beta!**
##Feature
+ You can use a custom data attribute in the event tracking.
+ Auto track the outbound link as an event.
+ Maybe works on IE6~, Fx3.6~, Safari, Chrome, Opera
+ Automatically load the "ga.js". (throuth script element)
+ 2kb to minimize. (without ie compatibility then 1.7kb)
+ Not dependent on any library.##Usage
hmm...
###Put
...
new GAS('UA-xxxxxxx-xx');
...
###Event tracking
// original
Done// gas.js
Done###Fake pageview tracking
// original
Fake page// gas.js
Fake page###Outbound link
###API
var gas = new GAS('UA-xxxxxxx-xx');
// track as a pageview
gas.trackPageview('/your_optional_path.html');// track as an event
gas.trackEvent('MusicPlayer', 'start', 'hogehoge');###for IE
This is anchor element.
For example, bind a click event using jQuery.
$('#clickable').bind('click', function() {
...return false;
});This 'click event' does not follow the 'document' and cannot event tracking. on Internet Explorer 6~8.
Solve this problem embed the following script, and class 'gas_prior' add to anchor element.
var gas = new GAS('UA-xxxxxxx-x');
jQuery(function() {
$('#clickable').bind('click', function(e) {
return false;
});// need DOM has been loaded
gas.priorityOver('gas_prior');
});
Actiongas.priorityOver method re-binding event to each element with class 'gas_prior'.
##ToDo
えいごあやしいすみませんすみません
+ popstate, hashchange時のトラッキングサポート
+ 子要素clickへの反応(parentNodeを辿ってdata-xxxを探索する)↓のようなdata属性の付与の仕方に対応したり
Start
Stop
Fav
##License
gas.js is licensed under the MIT licnese.