https://github.com/caleb531/goatcounter-js

A TypeScript-compatible package for easily integrating GoatCounter into your website

https://github.com/caleb531/goatcounter-js

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.9%) to scientific vocabulary
Last synced: 9 months ago · JSON representation

Repository

A TypeScript-compatible package for easily integrating GoatCounter into your website

Basic Info
  • Host: GitHub
  • Owner: caleb531
  • License: mit
  • Language: TypeScript
  • Default Branch: main
  • Size: 132 KB
Statistics
  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 7
Created almost 2 years ago · Last pushed over 1 year ago
Metadata Files
Readme License

README.md

GoatCounter JS

Copyright 2024 Caleb Evans
Released under the MIT license

GoatCounter JS is an (unofficial) JavaScript library that simplifies integrating GoatCounter into any JS framework. The API is small, TypeScript-compatible, and fully tree-shakable for the GoatCounter functions you actually use.

Setup

You can install GoatCounter via your preferred package manager (like npm, yarn, or pnpm):

sh npm install goatcounter-js

The basic usage is importing goatcounter, calling goatcounter.initialize(), then calling goatcounter.count(). You will probably want to pass { no_onload: true } in most cases.

```ts import * as goatcounter from "goatcounter-js";

// Configure how GoatCounter will be loaded goatcounter.initialize({ // Loads GoatCounter v4 script with SRI; // see https://www.goatcounter.com/help/countjs-versions scriptVersion: 4, // Define the endpoint containing your site code, as usual endpointUrl: "https://MYCODE.goatcounter.com/count", // Define your settings here (no need to stringify!); // see https://www.goatcounter.com/help/js#settings-421 // for all available settings settings: { noonload: true, allowlocal: true }, });

// Example with React function App() { // When route changes, send a pageview to GoatCounter; // you may need to adjust this logic depending on // how you handle routing in your app useEffect(() => { count(); }, []); } ```

Settings & Methods

GoatCounter JS supports all the same settings as the official JavaScript API, including the same defaults. Similarly, all the same methods are supported, including count(), get_query(), and others. The only difference is that these methods are async / return promises to ensure that GoatCounter is actually loaded on the page first.

Self-Hosted GoatCounter

If you have a self-hosted installation of GoatCounter, you only need to specify the custom URLs when initializing goatcounter-js (namely, the scriptSrc and endpointUrl properties):

```ts import * as goatcounter from "goatcounter-js";

goatcounter.initialize({ scriptSrc: "https://www.yourwebsite.com/count.js", endpointUrl: "https://insights.yourwebsite.com/count", settings: { noonload: true, allowlocal: true }, });

// ... ```

Owner

  • Name: Caleb Evans
  • Login: caleb531
  • Kind: user
  • Location: Carlsbad, CA

Hi, I'm Caleb, a web developer who lives for Christ by building enjoyable apps and useful tools. I hope you are blessed by what I've made!

GitHub Events

Total
  • Watch event: 1
  • Push event: 2
Last Year
  • Watch event: 1
  • Push event: 2

Packages

  • Total packages: 1
  • Total downloads:
    • npm 22 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 9
  • Total maintainers: 1
npmjs.org: goatcounter-js

An (unofficial) JavaScript library for integrating GoatCounter with your web framework of choice

  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 22 Last month
Rankings
Dependent repos count: 26.0%
Average: 31.9%
Dependent packages count: 37.8%
Maintainers (1)
Last synced: 10 months ago

Dependencies

.github/workflows/build.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • pnpm/action-setup v4 composite
.github/workflows/lint.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • pnpm/action-setup v4 composite
.github/workflows/publish.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • pnpm/action-setup v4 composite
src/versions.json meteor
package.json npm
  • @rollup/plugin-commonjs ^26.0.1 development
  • @rollup/plugin-json ^6.1.0 development
  • @rollup/plugin-typescript ^11.1.6 development
  • @types/node ^22.1.0 development
  • @typescript-eslint/eslint-plugin ^8.0.1 development
  • @typescript-eslint/parser ^8.0.1 development
  • eslint 8 development
  • eslint-config-prettier ^9.1.0 development
  • prettier ^3.3.3 development
  • rollup ^4.20.0 development
  • rollup-plugin-dts ^6.1.1 development
  • rollup-plugin-esbuild ^6.1.1 development
  • tslib ^2.6.3 development
  • typescript ^5.5.4 development
pnpm-lock.yaml npm
  • 228 dependencies