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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@wonderfulday/nuxt-mixpanel

v1.0.2

Published

Mixpanel Module for Nuxt.js

Readme

@wonderfulday/nuxt-mixpanel

npm version npm downloads License

Mixpanel Module for Nuxt.js

📖 Release Notes

Setup

  1. Add @wonderfulday/nuxt-mixpanel dependency to your project
yarn add @wonderfulday/nuxt-mixpanel # or npm install @wonderfulday/nuxt-mixpanel
  1. Add @wonderfulday/nuxt-mixpanel to the modules section of nuxt.config.js
export default {
  modules: [
    '@wonderfulday/nuxt-mixpanel',
  ],
  mixpanel: {
    id: '',
    config: {
      debug: true
    }
  }
}

Runtime Config

You can use runtime config if need to use dynamic environment variables in production. Otherwise, the options will be hardcoded during the build and won't be read from nuxt.config anymore.

export default {
  modules: [
    '@wonderfulday/nuxt-mixpanel'
  ],

  mixpanel: {
    id: '', // Used as fallback if no runtime config is provided
  },

  publicRuntimeConfig: {
    mixpanel: {
      id: process.env.MIXPANEL_ID,
    }
  }
}

Options

Defaults:

export default {
  mixpanel: {
    debug: false,

    enabled: true,

    id: undefined,
    windowStorageVariable: 'mixpanelStorage',

    pageTracking: false,
    pageViewEventName: 'nuxtRoute',

    autoInit: true,
    respectDoNotTrack: true,

    scriptId: 'nuxtMixpanel',
    scriptURL: 'cdn.mxpnl.com/libs/mixpanel-2-latest.min.js',
  }
}

enabled

Mixpanel module uses a debug-only version of $mixpanel during development (nuxt dev).

You can explicitly enable or disable it using enabled option:

export default {
  mixpanel: {
    // Always send real Mixpanel events (also when using `nuxt dev`)
    enabled: true
  }
}

debug

Whether $mixpanel API calls like track are logged to the console.

Manual Mixpanel Initialization

There are several use cases that you may need more control over initialization:

  • Block Mixpanel before user directly allows (GDPR realisation or other)
  • Dynamic ID based on request path or domain
  • Initialize with multi containers
  • Enable Mixpanel on page level

nuxt.config.js:

export default {
 modules: [
  '@wonderfulday/nuxt-mixpanel'
 ],
 plugins: [
  '~/plugins/mixpanel'
 ]
}

plugins/mixpanel.js:

export default function({ $mixpanel, route }) {
    $mixpanel.init('TOKEN')
}
  • Note: All events will be still buffered in data layer but won't send until init() method getting called.

Router Integration

You can optionally set pageTracking option to true to track page views.

The default event name for page views is nuxtRoute, you can change it by setting the pageViewEventName option.

Usage

Pushing events

You can push events into the configured layer:

this.$mixpanel.track('event name', {
    distinct_id: 'unique client id',
    property_1: 'value 1',
    property_2: 'value 1',
    property_3: 'value 1'
})

Development

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Start development server using yarn dev or MIXPANEL_ID=<your mixpanel token> yarn dev if you want to provide custom MIXPANEL_TOKEN.

Contributors

License

MIT License

Copyright (c) Wonderfulday