Google Analytics has been deemed illegal by the EU DPA. Undicat is a British company, operated fully on European infrastructure.

Using the library

The JavaScript library is an optional extension for our Undicat Analytics tracking script. It offers a couple of advantages.

  • Available instantly. No need to wait for the script to load
  • Auto-complete support. Thanks to the TypeScript typings
  • It automatically injects Undicat Analytics for you

The library builds on top of the Undicat Analytics script. There is no need to migrate if you don't see a benefit in the features listed above.

Installation

Use npm or yarn to install the package @undicat/analytics

yarn add @undicat/analytics

Basic Usage

After the installation, you can initialize it by running undicat.init(). After that it will track page views automatically. You can also use event tracking functions to track custom events as well as user properties.

Automatic page view tracking works with single-page applications out of the box. No matter if you use React, Vue.js, Angular, or any other front-end library that uses client-side routing.

import undicat from '@undicat/analytics';

// This initiliazes Undicat Analytics
undicat.init('YOUR_API_KEY')


// Track a custom event
undicat.send("Sign Up")


// Track an event with custom data
undicat.send("Choose Plan", {
  plan: "Business"
})


// Attach data to the current user - only a single string is supported
undicat.authenticate("balazs@undicat.com")

// Clears all user data. Should be used if an identified user logs out.
undicat.logout()

Advanced options

If you want to change the default settings, you can do so by providing them as argument to the init function.

import splitbee from '@splitbee/analytics';

splitbee.init('YOUR_API_KEY', {
  // Turn off all the default metrics to focus only on pagevies
  lite: false,

  // Disable media events
  disableMedia: false,

  // Disable input events
  disableInput: false,

  // Disable click events - including outbound links
  disableClicks: false,
  
  // Honouring Do Not Track
  dnt: false,
  
  // Start tracking automatically
  auto: true,

  // Ignore cannonicals
  ignoreCannonical: false,
  
  // Exclude specific subdomains
  excludeDomains: ['localhost', '*.ngrok.io'],
  
  // Whitelist only specific domains
  whitelistDomains: undefined;
  
  // Current application environment
  environment: 'PRODUCTION',

  // Current application release
  release: 'v1.0.2',

  // Current application language
  language: 'en-GB',

  // Type of Single Page Application navigation
  spa: 'history',

  // Endpoint used by the script
  endpoint: "https://api.undicat.com",
})

For more details about each of the options, please visit our Advanced Embed Settings to find the corresponding setting.

Using on the server

Our analytics package can be used on both the back-end and on the front-end, so you can use the same API if you want to send data to Undicat from your Node.js server.

Note: the pageview method will do absolutely nothing when used on the backend.

Finger printing

We use a fingerprinting logic to determine the unique visits by users.

When used on the backend, fingerprints should be set:

// Fingerprint (string), Unique user identifier - preferrably hashed
undicat.setFingerprint('FINGERPRINT')

Note: fingerprint can not be set when using in a browser

Sessions

We use a session logic, to group events from the same session.

For the best results we recommend setting the session as well:

// Session (string), Unique session identifier - preferrably hashed
undicat.setSession('SESSION')

Note: session can not be set when using in a browser