Socket
Socket
Sign inDemoInstall

nuxt-umami

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuxt-umami

Integrate Umami Analytics into Nuxt


Version published
Weekly downloads
2.2K
decreased by-8.42%
Maintainers
1
Weekly downloads
 
Created
Source

Nuxt Umami @next

npm Downloads License

Deeply integrate Umami Analytics into your Nuxt websites / applications.

Heads up: This version uses features (Nuxt Layers) that are only available in Nuxt 3. Check out Nuxt Umami v1 for Nuxt 2 compat.

Features

  • 📖 Open Source
  • ✨ SSR Support, of course
  • ➖ No extra script: no extra tag, no script loading, instant availability
  • 😜 Escapes ad & script blockers (catch me if you can)
  • 💯 Feature complete + extensive config
  • ✅ Better Typescript, JSDocs, auto completion
  • ✅ Error handling + debugging
  • ✅ Nuxt utils + auto import

Setup

Step 1: Installation and add to Nuxt

Install using your favorite package manager...

pnpm add nuxt-umami@next #pnpm
npm install nuxt-umami@next #npm

Then add nuxt-umami to your extends array in nuxt.config:

defineNuxtConfig({
  extends: ['nuxt-umami']
});

Or, you can totally skip the installation process and do

defineNuxtConfig({
  extends: ['github:ijkml/nuxt-umami#next']
});

Warning: This might cause unwanted errors due to changes as the branch is still WIP.

Step 2: Configure Umami

You can provide configuration options using the app.config.ts file or appConfig property of the Nuxt config.

app.config.ts file

(recommended for readability and ease of update)

export default defineAppConfig({
  umami: {
  // ...umami config here
  },
});
appConfig property
defineNuxtConfig({
  extends: ['nuxt-umami@next'],
  appConfig: {
    umami: {
      // ...umami config here
    },
  },
});

Step 3:

Use it?

Configuration

optiontypedescriptionrequireddefault
hoststringYour Umami endpoint. This is where your script is hosted. Eg: https://ijkml.xyz/.true''
idstringUnique website-id provided by Umami.true''
domainsstringLimit tracker to specific domains by providing a comma-separated list (without 'http'). Leave blank for all domains.false''
ignoreDntbooleanOption to ignore browsers' Do Not Track setting.falsetrue
autoTrackbooleanOption to automatically track page views.falsetrue
ignoreLocalhostbooleanOption to prevent tracking on localhost.falsefalse

Usage

Two functions are auto-imported, umTrackView() and umTrackEvent(). Use them however and wherever you like.

Available Methods

  • umTrackView(url, referrer)

    • url: the path being tracked, eg /about, /contact?by=phone#office. Most times, this can be correctly inferred. Equivalent of router.fullPath.
    • referrer: the page referrer. Most times, this can be correctly inferred. Equivalent of document.referrer.
  • umTrackEvent(eventName, eventData)

    • eventName: a string type text
    • eventData: could be string, number, array or object

Reference: Umami Tracker Functions.

Issues, Bugs, Ideas?

Open an issue, fire a PR. Contributions are welcome! If you encounter any issues, don't hesitate to open an issue. I'm always available to help and resolve any bugs.

Contributors

Nuxt Umami contributors

MIT License © 2023 ML

Keywords

FAQs

Package last updated on 22 Feb 2023

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