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

analytics-plugin-defer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

analytics-plugin-defer

Analytics plugin to defer loading plugins until page interaction has occurred

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-80%
Maintainers
1
Weekly downloads
 
Created
Source

Defer plugin for analytics

Facilitates defering other analytics plugins and their associated events tracked with analytics. For example delay loading google-tag-manager in order to increase PageSpeed and once the deferred plugin is loaded then relay the events that occured prior to it loading to the now loaded plugin.

Installation

npm install analytics analytics-plugin-defer

How to use

To use, install the package, include in your project and initialize the plugin with analytics.

Below is an example of how to use the browser plugin.

import Analytics from 'analytics';
import googleTagManager from '@analytics/google-tag-manager';
import deferPlugin from 'analytics-plugin-defer';

const analytics = Analytics({
  app: 'example',
  plugins: [
    deferPlugin({ plugins: ['google-tag-manager'] }),
    googleTagManager({
      containerId: 'GTM-123456',
      enabled: false,
    }),
  ],
});

/* Track a page view */
analytics.page();

/* Track a custom event */
analytics.track('customEvent', {
  signup: true,
});

/* Identify a visitor */
analytics.identify('user', {
  firstName: 'Foo',
  lastName: 'Bar',
});

/* Deferred plugin will only load and be sent above events once the user iteracts with the page */

After initializing analytics with the analyticsDefer plugin, tracking data will be stored temporarily whenever analytics.page, analytics.track, or analytics.identify are called and will only be sent after there is interaction with the page upon which the deferred plugin is then loaded and the events are replayed.

Configuration options

Optiondescription
plugins
required - string[]
A list of all the plugin names to defer until there is interactoin with the page

FAQs

Package last updated on 14 Sep 2021

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