New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@data-visuals/analytics

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@data-visuals/analytics

Consistently track how pages perform the Texas Tribune Data Visuals way.

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

Data Visuals Analytics

An easy way to hook up Google Analytics (and any future trackers!) in Data Visuals projects.

Installation

npm install @data-visuals/analytics

Usage

Two of autotrack's plugins are included in this library — cleanUrlTracker and eventTracker. cleanUrlTracker is already pre-configured and requires no extra work, but eventTracker only enables what's detailed in the documentation for that plugin and will require extra tagging in your HTML.

This library does not load the Google Analytics library for you. You'll still need to ensure that makes it on the page. However, @data-visuals/analytics expects that to happen asynchronously so it can be loaded at any time.

In your HTML (either right before your <body> element closes, or at the bottom of the <head>), load the Google Analytics library.

<!-- Google Analytics -->
<script async src="https://www.google-analytics.com/analytics.js"></script>
<!-- End Google Analytics -->

The library exports an init() function to be called. It's recommended that you use Webpack's code splitting functionality (if your environment supports it) to load this library so nothing is blocked by its loading.

import(/* webpackChunkName: "analytics" */ '@data-visuals/analytics').then(
  analytics => analytics.init()
);

If for some reason you don't want to do that, or you're using this somewhere that isn't allowed, importing it and calling it normally will also work.

import { init } from '@data-visuals/analytics';

init();

API

init

Initializes all the analytics setup. Creates trackers and sets initial values on the trackers.

Parameters

  • options Object (optional, default {})
    • options.linkerDomains Array<String> List of domains to pass to linker plugin (optional, default DEFAULT_LINKER_DOMAINS)
    • options.trackingId String Google Analytics tracking ID (optional, default DEFAULT_TRACKING_ID)

Examples

// Async method
import('@data-visuals/analytics').then(analytics => analytics.init());

// Standard import method
import { init } from '@data-visuals/analytics';

init();

Returns void

License

MIT

Keywords

FAQs

Package last updated on 12 Feb 2018

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