@xpertsea/sea-analytics v2.0.0
Sea Analytics
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-analyticsContribute
VSCode plugins
Requirements
Clone
git clone git@github.com:Xpertsea/sea-analytics.git
cd sea-analytics
yarn installView documentation
yarn docTest
yarn testLint
yarn lint7 years ago