1.2.1 • Published 3 years ago
action-tracker v1.2.1
action-tracker.js
The easy-to-use library for Google Analytics's tracking.
Installation
bower install --save action-trackernpm:
npm install --save action-trackerExamples
<script src="dist/action-tracker.min.js"></script>
<script>
ga('create', {YOUR PROPERTY ID})
</script>
<script>
var tracker = ActionTracker()
$('a[data-tracker]').on('click', function () {
tracker.emit('anchor', 'click', $(this).text())
})
</script>Documantation
tracker(options)
Create a tracker.
By default property id is null. In the case we will use the configured of ga object.
- options.id optional ... Analytics's property id.
- options.name optional ... Tracker's name option. Call the method with a name (
ga('name.method', value)) when you specify.
tracker.set(name, value)
Set the name and value to the ga object.
tracker.send(name , options)
Call the send method from ga object.
- name required ... The
methodname. - options optional ... The object of the
fieldsyou want to send. By default sendnull.
tracker.pageview(path)
Send the page-view.
- path optional ... The URL's path for send. By default send the
tracker.get('path')
tracker.emit(category, action, label , value)
Send event.
- category required ... Event category.
- action required ... Event action.
- label optional ... Event label. By default, set a
''. - value optional ... Event value. By default, set a
null.
tracker.exception(error_message, options)
Send the exception.
- error_message required ... description of the exception or
Errorobject. serialize to json format string. - options.fatal optional ... GA's
exFatalflag. By default, set afalse.
LICENSE
MIT