Skip to content

nuxt-ripple-analytics 2.22.1-next.064b5bb59.42

Install from the command line:
Learn more about npm packages
$ npm install @dpc-sdp/nuxt-ripple-analytics@2.22.1-next.064b5bb59.42
Install via package.json:
"@dpc-sdp/nuxt-ripple-analytics": "2.22.1-next.064b5bb59.42"

About this version

Nuxt Ripple Analytics

A Nuxt module for handling event tracking using to Google Analytics.

Installation

To use this package in your Nuxt project first install it with npm

npm install @dpc-sdp/nuxt-ripple-analytics

Usage

Add the installed package in your sites nuxt.config.js file under the extends property, this includes the package as a Nuxt Layer.

export default defineNuxtConfig({
  extends: [
    '@dpc-sdp/nuxt-ripple-analytics'
  ]
})

Configuration

The Runtime variable for the GTM container ID can be set in the nuxt.config.js.

export default defineNuxtConfig({
  runtimeConfig: {
    public: {
      tide: {
        analytics: {
          GTM: ''
        }
      }
    }
  }
})

It can also be set as an environment variable.

# GTM container - this should be common to all SDP sites utilising WoVG analytics
NUXT_PUBLIC_TIDE_ANALYTICS_GTM=GTM-XXXXXXX

The App config file can be used to add additional event listeners, as well as disable or override the default route change event.

import { trackEvent } from '@dpc-sdp/nuxt-ripple-analytics/events'

export default defineAppConfig({
  ripple: {
    analytics: {
      // routeChange events are enabled by default
      // this parameter can be set to false to disable routeChange events
      // or optionally, an object can be used to extend or override the default routeChange event
      routeChange: {
        app: ({ payload, page }) => ({
          // optionally include default event data
          ...payload,
          // add custom event data
          promoted: true
        })
      },

      // custom events listeners can be added here
      eventListeners: {
        'my-custom-event': () => {
          return (payload) => {
            trackEvent({
              // custom event data
              event: payload.action
            })
          }
        }
      }
    }
  }
})

Details


Assets

  • nuxt-ripple-analytics-2.22.1-next.064b5bb59.42.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0