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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rabota/google-analytics

v0.9.2

Published

The most powerful module to work with Google Analytics in your Nuxt.js application

Downloads

22

Readme

Google Analytics

npm npm (scoped with tag)

Add Google Analytics to your nuxt.js application.

This plugins automatically sends first page and route change events to Google Analytics.

yarn add @rabota/google-analytics

or

npm install --save @rabota/google-analytics

Table of contents

Features

  • Supports multiple IDs
  • You can pass an async function to provide IDs
  • Easy-to-use API
  • Automatically handling all SPA caveats (spa: true option)
  • gtag API
  • Logging

Note: Google Analytics is disabled in development mode by default. You can set development option to true to run Google Analytics in development mode.

Setup

  • Add @rabota/google-analytics dependency using yarn or npm to your project
  • Add @rabota/google-analytics to modules section of nuxt.config.js
{
  modules: [
    ['@rabota/google-analytics', [
      counter: 'GA_TRACKING_ID', // main tracking ID
      includeCounters: [ 'GA_TRACKING_ID_2', ..., 'GA_TRACKING_ID_3' ], // additional tracking IDs
      options: {
       // google analytics options
      },
      spa: true, // sends new pages to GA in SPA
      logging: true, // logs all events to each counter
      development: true
    }]
  ]
}

Options

counter

{string|Function} Tracking ID

Could be an async function that returns an ID.

includeCounters

{string|Array<string>|Function} Additional tracking IDs

Could be an async function that returns one or array of IDs.

options

{Object} Google Analytics (todo)

spa

{boolean} Sends new pages & pageviews to GA in SPA (default: true).

logging

{boolean} Output all sending events for each counter (default: false).

development

{boolean} set true if you want to run GA in dev mode. By default GA is disabled in dev mode.

Methods

this.$ga - is a Layer Instance.

#pushAll

Same as gtag function of GA. Sends data to all trackers.

#pushTo

The same as gtag function of GA. Sends data to specific tracker.

More information about GA routing: https://developers.google.com/gtagjs/devguide/routing

More methods or properties you can find here: @rabota/analytics-layer/src/layer.js.

Examples

After setup you can access the GA through this.$ga instance in any component you need.

export default {
  mounted () {
    this.$ga.pushAll('event', 'add_to_cart', {
      'items': [
        'id': 'U1234',
        'ecomm_prodid': 'U1234',
        'name': 'Argyle Funky Winklepickers',
        'list': 'Search Results',
        'category': 'Footwear',
        'quantity': 1,
        'ecomm_totalvalue': 123.45,
        'price': 123.45
      ]
    });
  }
}

Send to a specific tracker

export default {
  mounted () {
    this.$ga.pushTo( 'GA_TRACKING_ID', 'event', 'event-name', params );
  }
}

Links

License

MIT

Author

Alexander Belov (c) 2019