@cnbritain/merlin-frontend-gatracker-js

Google analytics wrapper

Usage no npm install needed!

<script type="module">
  import cnbritainMerlinFrontendGatrackerJs from 'https://cdn.skypack.dev/@cnbritain/merlin-frontend-gatracker-js';
</script>

README

merlin-frontend-gatracker-js

Google analytics wrapper

JS Documentation

GATracker

Kind: global class

new GATracker(id, _config)

Param Type Description
id String The GA unique id
_config Object

gaTracker.send(hitType, config)

Fires a ga send call

Kind: instance method of GATracker
Access: public

Param Type Description
hitType String
config Object Data to send along with the call

gaTracker.set(fieldName, value)

Fires a ga set call to set information

Kind: instance method of GATracker
Access: public

Param Type Description
fieldName String/Object Either a key or an object with data
value String/Number

GATracker.TRACKERS : Array

List of trackers that have been created

Kind: static property of GATracker

GATracker.INDEX_BY_DIMENSION : Object

Lookup table of dimension index by dimension label

Kind: static property of GATracker

GATracker.DIMENSION_BY_INDEX : Object

Lookup table of dimension labels by dimension index

Kind: static property of GATracker

GATracker.TRACKING_BRAND_ID : String

The GA tracking id of the site. This will be updated in the page template.

Kind: static property of GATracker

GATracker.TRACKING_CONDE_ID : String

The GA tracking id for CondeNast

Kind: static property of GATracker

GATracker.COMSCORE_PUBLISHED_ID : Number

Comscore id

Kind: static property of GATracker

GATracker.RE_SITE : RegExp

RegEx for brand site This isn't set because each brand should specify in the core

Kind: static property of GATracker

GATracker.REFERRERS : Object

List of referrer types

Kind: static constant of GATracker

GATracker.SEND_HITTYPES : Object

List of ga send hit types

Kind: static constant of GATracker

GATracker.SendAll(hitType, config)

Calls send on all the trackers

Kind: static method of GATracker

Param Type
hitType String
config Object

GATracker.SetAll(fieldName, value)

Calls set on all the trackers

Kind: static method of GATracker

Param Type
fieldName String/Object
value String/Number

GATracker.getDimensionByIndex(index) ⇒ String

Gets the dimension label by dimension index

Kind: static method of GATracker
Returns: String - The dimension label

Param Type
index String

GATracker.getIndexByDimension(dimension) ⇒ String

Gets the dimension index by dimension label

Kind: static method of GATracker
Returns: String - The dimension index

Param Type
dimension String

Prerequisites:

  • Node.jsbrew install node
  • Grunt - npm install -g grunt-cli
  • Other prereqs? Python? Virtualenv?

Demo:

Install dependencies:

npm install

Build the things:

npm run sass
npm run js
npm run docs

Hint your JS

npm run jshint

Python the pythons:

npm run demo-install

Start the demo server:

python demo.py