whatisgithub

What is analytics.js?

segmentio/analytics.js — explained in plain English

Analysis updated 2026-06-26

4,759JavaScriptAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

A JavaScript library that sends your website's user-behavior events to 250+ analytics services at once with a single API call. Add or remove destinations from a dashboard without touching your code.

Mindmap

mindmap
  root((analytics.js))
    What it does
      Single tracking call
      250+ destinations
    Features
      Fan-out to services
      No-code destination toggle
      Data warehouse support
    Use Cases
      Event tracking
      User identification
      Marketing analytics
    License
      MIT permissive
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Track a user signup once and automatically send the event to Google Analytics, Mixpanel, and Facebook Ads simultaneously.

USE CASE 2

Switch analytics destinations on or off from a settings dashboard without deploying new code.

USE CASE 3

Send user behavior data to a warehouse like Amazon Redshift or Google BigQuery for SQL querying.

What is it built with?

JavaScript

How does it compare?

segmentio/analytics.jsgitpoint/git-pointtransitive-bullshit/create-react-library
Stars4,7594,7604,761
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasymoderateeasy
Complexity2/53/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

This is the legacy version, the README recommends analytics-next for new projects.

Free to use for any purpose, including commercial use, as long as the MIT license notice is kept.

So what is it?

Analytics.js is an open-source JavaScript library built by Segment that lets you track user behavior on a website and send that data to many different analytics services at once. Instead of writing separate code for each tool you want to use, such as Google Analytics, Mixpanel, or Facebook Ads, you write a single set of API calls and the library handles routing the data to every destination you have switched on. You can add or remove any service from a settings dashboard without touching your code again. The main idea is a single tracking call that fans out to multiple tools. When a user completes an action on your site, you record that event once, and the library forwards it to whichever services you have connected. The project supports more than 250 destinations, covering categories like email marketing, advertising platforms, session recording, and data warehouses such as Amazon Redshift and Google BigQuery. Sending data to a warehouse also lets you query your user behavior history in SQL without building your own data pipeline. This repository contains a pre-built, standalone version of the library that you can use without a paid Segment subscription. If you need a smaller build with only the plugins relevant to your setup, the project wiki explains how to compile a custom version. The core logic and each integration plugin live in separate repositories under the Segment GitHub organization, so issues can be filed against the right piece. One thing worth knowing: this is the older generation of the library. The README itself links to a newer version called analytics-next as the current recommended path. If you are starting a new project with Segment today, that repository is likely where you should begin. The library is released under the MIT license.

Copy-paste prompts

Prompt 1
Using analytics.js, write the JavaScript snippet to track a 'Purchased' event with properties: item name, price, and quantity, and show how it fans out to multiple destinations.
Prompt 2
I want to set up analytics.js on my website to send events to both Google Analytics and Mixpanel. Walk me through the script tag installation and first identify() and track() calls.
Prompt 3
Using analytics.js, how do I send user identity information (name, email, plan tier) when a user logs in so all downstream analytics tools receive that context?
Prompt 4
Show me how to build a custom analytics.js integration plugin that forwards events to my own API endpoint.

Frequently asked questions

What is analytics.js?

A JavaScript library that sends your website's user-behavior events to 250+ analytics services at once with a single API call. Add or remove destinations from a dashboard without touching your code.

What language is analytics.js written in?

Mainly JavaScript. The stack also includes JavaScript.

What license does analytics.js use?

Free to use for any purpose, including commercial use, as long as the MIT license notice is kept.

How hard is analytics.js to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is analytics.js for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.