@melmacaluso/skadi v1.3.3
Skadi.js 0.0.0-semantically-released
A simple js class to send tracking events to your google analytics account
skadi.js
new Skadi()
Main Skadi.js class
Returns
- Void
Skadi.constructor(options)
Parameters
| Name | Type | Description | |
|---|---|---|---|
| options | object | Sets the custom user defined arguments. | 
Properties
| Name | Type | Description | |
|---|---|---|---|
| options | object | Sets the custom user defined arguments. | 
Returns
- Void
Skadi.logDebug(logItems, message)
Simple logger for the debug mode.
Parameters
| Name | Type | Description | |
|---|---|---|---|
| logItems | array | Items to be logged in the console | |
| message | string | Arbitrary message that goes along the logItems | 
Returns
- Void
Skadi.updatePropsOnLoad()
Updates the class propreties with user defined ones after the page has loaded and if there's a window.Skadi object in place.
Returns
- Void
Skadi.getEventType(event)
Filters the event types and gets the DOM node element clicked/focused. It also sets the class constructor's proprieties accordingly and filters out event types that are not allowed updating elementAllowed property accordingly. It also prevents registering continous events when the target is a input or textarea on keyup events that are not key === 'Tab'
Parameters
| Name | Type | Description | |
|---|---|---|---|
| event | object | Either the mousevent or keyevent event object. | 
Returns
- Void
Skadi.parseElementClickedTag()
Translates event types to human readable events.
Returns
- stringThe layman's terms event type.
Skadi.getElementClickedAction()
Parses the the GA action to be human readable.
Returns
- stringThe action's type and target.
Skadi.getElementClickedContext()
Gets the nearest data-skadi-context bubbling up until finding a context or to the user defined maxBubbling value.
Returns
- stringThe nearest context or "Default context" if nothing found.
Skadi.getElementClickedLabel()
Gets and parses the the GA Label to be human readable assuming canonical html is being used for label tags.
Returns
- stringThe label parsed.
Skadi.parseToGaEvent(event)
Updates Skadi's constructor properties with the relevant parsed action, category and label and triggers GA function to send the GA event.
Parameters
| Name | Type | Description | |
|---|---|---|---|
| event | object | The click or keyboard event. | 
Returns
- Void
Skadi.sendToGa()
Sends the events to GA.
Returns
- Void
Skadi.addClickListener()
Adds click and keyup listeners to the window global.
Returns
- Void
Skadi.init(isCDN)
Initialises Skadi bootstrapping the listeners. It prevents es module version of skadi to work if there's a CDN version embedded.
Parameters
| Name | Type | Description | |
|---|---|---|---|
| isCDN | boolean | Disables errors in CDN versions of skadi. | 
Returns
- Void
Documentation generated with doxdox.