2.0.0 • Published 6 years ago

@xpertsea/sea-analytics v2.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
6 years ago

Sea Analytics

Build Status

JavaScript Style Guide

Includes

sea-analytics

A Sea element to add Google Analytics to your app. It imports google-analytics.js asynchronously, configures trackers and sends pageview commands. See Google developers' website for more details.

Usage

The simplest way to use this component is to include it where you route between pages and bind the selected page's name and current user like this:

  <sea-analytics
    tracking-id="UA-XXXXX-Y"
    user-id="[[user.id]]"
    page-name="[[page.name]]"></sea-analytics>

This will create a global tracker that sends pageview commands whenever the user changes page. Or you can include it in multiple sections throughout your app to create multiple fine-grained tracker, like this:

  <sea-analytics
    tracking-id="UA-XXXXX-Y"
    tracker-name="user-section"
    user-id="[[user.id]]"
    page-name="[[userSectionPage.name]]"></sea-analytics>

You can also add custom user dimensions through the userDimensions property. The provided value should be an array of objects with id and value properties corresponding to the custom dimensions configured on your Google Analytics account, example:

import { SeaAnalytics } from '@xpertsea/sea-analytics/sea-analytics.js'

const analytics = new SeaAnalytics()
analytics.set('userDimensions', [
  {
    id: 'dimension1',
    value: 'YOUR_USER_VALUE'
  }
])

Install

yarn add @xpertsea/sea-analytics

Contribute

VSCode plugins

Requirements

Clone

git clone git@github.com:Xpertsea/sea-analytics.git
cd sea-analytics
yarn install

View documentation

yarn doc

Test

yarn test

Lint

yarn lint