Socket
Socket
Sign inDemoInstall

action-tracker

Package Overview
Dependencies
858
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    action-tracker

The easy-to-use library for Google Analytics's tracking.


Version published
Weekly downloads
222
decreased by-4.31%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

action-tracker.js

The easy-to-use library for Google Analytics's tracking.

npm version Bower version Build Status Codacy Badge Code Climate Test Coverage Dependency Status

Installation

bower:

bower install --save action-tracker

npm:

npm install --save action-tracker

Examples

<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.

  • name [required] ... The fields's name.
  • value [required] ... The fields's value.

tracker.send(name [, options])

Call the send method from ga object.

  • name [required] ... The method name.
  • options [optional] ... The object of the fields you want to send. By default send null.

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 Error object. serialize to json format string.
  • options.fatal [optional] ... GA's exFatal flag. By default, set a false.

LICENSE

MIT

Keywords

FAQs

Last updated on 26 Feb 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc