npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@statcounter/angular

v0.1.3

Published

Official StatCounter wrapper for Angular applications

Readme

@statcounter/angular

The official Angular wrapper for StatCounter. This library provides a seamless integration of the StatCounter tracking code into Angular applications, automatically tracking page views as the user navigates through your Single Page Application (SPA).

Features

  • Automatic Page Tracking: Automatically triggers a page view on every NavigationEnd event from the Angular Router.
  • Invisible Tracking: Optimized for modern web design standards.
  • SSR Compatible: Safely checks for browser environments to prevent errors during Server-Side Rendering (Angular Universal).

Installation

Run the following command to install the package:

npm install @statcounter/angular

Setup for Angular 15+

Use this method if you are using Angular 15+ with app.config.ts.

In your app.config.ts make these 3 changes.

Top :

import { importProvidersFrom } from '@angular/core';

import { StatCounterModule } from '@statcounter/angular';

Bottom :

importProvidersFrom(
      StatCounterModule.forRoot({
        project_id: 12345678,     // Your Project ID
        security_code: 'abcabc' // Your Security Code
      })
    )

Important : You must add a comma , to the element above the StatCounter importProvidersFrom block. See example code below.

Example app.config.ts file

import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';

// ADD THESE TWO LINES
import { importProvidersFrom } from '@angular/core';
import { StatCounterModule } from '@statcounter/angular';

export const appConfig: ApplicationConfig = {
  providers: [
    provideRouter(routes),		// <--- Don't forget the comma here
    
    // ADD StatCounter block
    importProvidersFrom(
      StatCounterModule.forRoot({
        project_id: 123123123,     // Your Project ID
        security_code: 'abcabc' // Your Security Code
      })
    )
    // StatCounter block ends here
  ]
};

Setup (Legacy / NgModules)

If your application uses the traditional app.module.ts, add StatCounterModule.forRoot() to your imports.

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';

import { AppComponent } from './app.component';
import { StatCounterModule } from '@statcounter/angular';

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    RouterModule.forRoot([]), // Router is required
    
    // Initialize StatCounter
    StatCounterModule.forRoot({
      project_id: 123123123,
      security_code: 'abcabc'
    })
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

Configuration Options

| Option | Type | Required | Description | | :--- | :--- | :--- | :--- | | project_id | number | Yes | The Project ID found in your StatCounter dashboard. | | security_code | string | Yes | The Security Code found in your StatCounter dashboard. |

Note: The StatCounter is invisible by default and you don't need to configure sc_invisible

How to Verify

  1. Serve your application (ng serve).
  2. Open your browser's Developer Tools (F12).
  3. Go to the Network tab.
  4. Filter by statcounter.
  5. Open your site and navigate between pages in your Angular app.
  6. You should see a request to counter.js and a new request to t.php for every navigation event.

License

MIT