nuxt-ripple-analytics 2.22.1-next.824bb9965.54
Install from the command line:
Learn more about npm packages
$ npm install @dpc-sdp/nuxt-ripple-analytics@2.22.1-next.824bb9965.54
Install via package.json:
"@dpc-sdp/nuxt-ripple-analytics": "2.22.1-next.824bb9965.54"
About this version
A Nuxt module for handling event tracking using to Google Analytics.
To use this package in your Nuxt project first install it with npm
npm install @dpc-sdp/nuxt-ripple-analytics
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'
]
})
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
- nuxt-ripple-analytics
- dpc-sdp
- 10 days ago
- Apache-2.0
- 16 dependencies
Assets
- nuxt-ripple-analytics-2.22.1-next.824bb9965.54.tgz
Download activity
- Total downloads 12
- Last 30 days 12
- Last week 0
- Today 0