plurall-tracker

An unified tracking library for all Plurall front-end projects.

Usage no npm install needed!

<script type="module">
  import plurallTracker from 'https://cdn.skypack.dev/plurall-tracker';
</script>

README

Tracker

An unified tracking library for all Plurall front-end projects.

Installation

If using npm, run yarn add plural-tracker or npm install plurall-tracker.

Otherwise, include <script src=""> in your index.html.

Once the lib is properly installed in your project, initialize it as soon as required:

window.tracker = new Tracker({
  environment: 'development|staging|production',
  clientId: 'project-identifier',
})

In Browser

<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.6.0/polyfill.min.js"></script>
<script src="https://assets.cdn.plurall.net/tracker/{{VERSION-PACKAG.JSON}}.js"></script>
<script>
  window.onload = function() {
    window.tracker = new PlurallTracker({
      environment: 'staging',
      clientId: 'test',
    })

    window.tracker.pageView()
    window.tracker.track('click:video_external', { videoid: 98282 })
  }
</script>

Usage

In conformance with tracking guidelines defined by the data team, all events contain the following default information about the user and his/her device:

{
  user = {
    mail,
    plurall_id,
    somos_id,
    class_ids[],
    class_names[],
    grade_ids[],
    grade_names[],
    level_ids[],
    level_names[],
    network_ids[],
    network_names[],
    role_ids[],
    role_names[],
    unit_ids[],
    unit_names[],
    unit_somos_ids[],
    year_ids[],
    year_names[],
  },

  device = {
    description: (user-agent),
    type: 'web',
  }

  page: (document-title),
  location: (window-location),
}

Additional required data concerning a particular event must be explicitly assigned (see below).

This lib exposes a pageView method:

window.tracker.pageView(custom - params - object)

Besides the example above, it also exposes a single generic tracking method, with the signature .track(event: String, params: Object) :

window.tracker.track('event-to-track', customParamsObject)

Hotjar

You can load the hotjar script using the hotjarId parameter (e.g.):

window.tracker = new Tracker({
  environment: 'development|staging|production',
  clientId: 'project-identifier',
  hotjarId: 123456,
})