Socket
Socket
Sign inDemoInstall

@aller/blink

Package Overview
Dependencies
Maintainers
16
Versions
227
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aller/blink

A library for tracking user behaviour.


Version published
Weekly downloads
757
increased by11.32%
Maintainers
16
Weekly downloads
 
Created
Source

Library for user behaviour tracking.

Goals

The main goal is to make tracking of user behavior in news sites easy.

  • be easy to configure
  • not use much resources
  • have a small bundle size
  • batch tracking events together before sending
  • be GDPR compliant
  • send data when the user leaves the page

Pageload Tracking

  • Is the user a DB Pluss user?
  • Which ab-testing group is the user a part of?

Element Tracking

This can be tracking of elements like article previews and ads.

  • has it been seen by the user (inscreen)?
  • has it been clicked on by the user (clicks)?
  • has it been loaded (load)?
  • where is it on the page (position)?
  • where was the user when it loaded (load position)?
Ad Specific Things
  • track DFP

Activity Tracking

Tracking of general user activity.

  • how long has the user been active on the page (active time)?
    • stop the active time counter if the user is inactive for n seconds or makes the page inactive

GDPR Tracking

  • has the user opted in or out of GDPR items?

API

This is an idea of how we would like this library to be used.

Multi page applications (Labrador)

import blink from '@aller/blink';

blink.configure({
  sendUrl: 'https://aas.medialaben.no/a',
  sendInterval: 20000,
  batchLimit: 3,
  batchedSendInterval: 5000,
});

// Track active time
blink.trackActiveTime({
  url: document.head.querySelector('meta[property="og:url"]'), // default: window.location.href
});

// Track page load
blink.trackPageLoad({
  url: window.location.href,
});

// Track article clicks
blink.trackArticlePreviewClick({
  selector: 'article.preview,.article-list>li',
  // The url is parsed from the dom
});

// Track article impressions
blink.trackArticlePreviewImpression({
  selector: 'article.preview,.article-list>li',
  // The url is parsed from the dom
});

Single Page Applications (Sol)

// Inside a root config file
import { BlinkProvider } from '@aller/blink';

return (
  <BlinkProvider
    prodUrl="https://aas.medialaben.no/a"
    devUrl="http://localhost:3000/a"
    sendInterval={20000}
    batchLimit={3}
    batchedSendInterval={5000}
    trackActivity={false}
    trackPageload={true}
  >
    <App />
  </BlinkProvider>
);

Handling clicks manually

// Inside a React component
import { BlinkTracker } from '@aller/blink';

return (
  <BlinkTracker>
    ({trackClick}) =>
    <Article onClick={() => trackClick({ id: article.id, url: article.url })} />
  </BlinkTracker>
);

Handling impressions

No function calls are needed, because the impression is on the container element

import { BlinkTrackerImpression } from '@aller/blink';

return (
  <BlinkTrackerImpression url={article.url} threshold={0.5}>
    <Article id={article.id} url={article.url} />
  </BlinkTrackerImpression>
);

Keywords

FAQs

Package last updated on 23 Jul 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