Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@siteminder/canvas-analytics-js

Package Overview
Dependencies
Maintainers
128
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@siteminder/canvas-analytics-js

Canvas Analyti

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
471
decreased by-32.23%
Maintainers
128
Weekly downloads
 
Created
Source

Canvas Analytics Javascript Plugin

Canvas Analytics Javascript Plugin

Configurable lightweight analytics utility for web

Installation

npm install @siteminder/canvas-analytics-js --save

Usage

Here is a quick example to get you started, it's all you need:


const config = {
  serverUrl: "http://localhost:3040/api/v1/collect",
  session: 'cd3',
  trackers: [
    {
      target: {
        selectorType: "direct",
        object: window,
        eventType: "load"
      },
      hit: {
        type: "pageview",
        data: {
          cd2: "propertyId"
        }
      }
    },
    {
      target: {
        selectorType: "direct",
        object: window,
        eventType: "hashchange"
      },
      hit: {
        type: "pageview"
      }
    },
    {
      target: {
        selectorType: "querySelector",
        matcher: "#testBtn",
        eventType: "click"
      },
      hit: {
        type: "event",
        data: {
          ec: "tester-category",
          ea: "tester-action",
          el: "tester-label",
          ev: 1000
        }
      }
    }
  ]
};
const analytics = new Analytics(config);
analytics.init();

Configuration

Config(Object)
|- session(string): this field is optional. When it's enabled, a uuid string will be injected to hit.data object
|- target(Object)
|--- selectorType(string): "querySelector" / "direct"
|--- matcher(string):  when querySelector is chosen: valid CSS selector(s) syntax
|--- object(Object):   when direct is chosen: window / document or other similar DOM object
|--- eventType(string): all supported DOM event handlers e.g. onclick
|- hit(Object)
|--- type(string): "pageview", "event"
|--- data(Object): any kind of data you want to pass to your severs like a ga compatible object

Current custom dimensions used as data keys in Analytic API;

  • cd1: user-agent - Derived on the server from the client request header.
  • cd2: propertyId - Hotel/Site unique identifier.
  • cd3: sessionId - Session ID generated and stored in localStorage in the browser.
  • cd4: host - Property domain/host name. This is derived and passed to GA from Analytics API directly.

Methods

  • init() - init the plugin

Caveat

Please put the canvas-analytics-plugin ahead of its bootstrap code snippet.

You are welcome to use the following pattern to load the code:

<script src="./dist/analytics.umd.js" defer async></script>
<script src="./your-bootstrap-code.js" defer async></script>

in the file ./your-bootstrap-code.js
...
const config = {...}
const analytics = new Analytics(config);
analytics.init();
...

Setup

# install
npm install

# compile
npm run compile

# run app
npm run dev
npm run dev:browser

# test
npm run test

Releases

Detailed changes for each release are documented in the release notes.

Commit Messages Guidelines

Detailed commit guidelines are documented in the Commit Messages Guidelines

FAQs

Package last updated on 09 Oct 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc