Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nuxtjs/google-gtag

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxtjs/google-gtag - npm Package Compare versions

Comparing version 0.0.4 to 1.0.2

lib/templates/config.js

34

CHANGELOG.md

@@ -5,2 +5,36 @@ # Change Log

<a name="1.0.2"></a>
## [1.0.2](https://github.com/https://github.com/nuxt-community/google-gtag/compare/v1.0.1...v1.0.2) (2018-05-17)
<a name="1.0.1"></a>
## [1.0.1](https://github.com/https://github.com/nuxt-community/google-gtag/compare/v0.0.5...v1.0.1) (2018-05-17)
<a name="0.0.5"></a>
## [0.0.5](https://github.com/https://github.com/nuxt-community/google-gtag/compare/v0.0.4...v0.0.5) (2018-05-17)
Removed dependency of `vue-gtag`
Bugfix:
* this.$gtag() works not correctly in components
Improved:
* new options `disableAutoPageTrack`
* Debug improved to track all `$gtag()` calls and prints out the arguments
* added test for event tracking
Breaking Change:
* `options` renamed to `config`
```js
// nuxt.config.js
'google-gtag':{
id:'ID_XX_XX',
config: {
// your gtag options
}
}
```
<a name="0.0.4"></a>

@@ -7,0 +41,0 @@ ## [0.0.4](https://github.com/https://github.com/nuxt-community/google-gtag/compare/v0.0.3...v0.0.4) (2018-05-11)

18

lib/module.js

@@ -7,12 +7,24 @@ const {resolve} = require('path')

if (options && options.id) {
if (!isProd && !options.options.debug) {
if (!isProd && !options.debug) {
return // disable if not debug mode
}
this.options.head.script.push({
src: `https://www.googletagmanager.com/gtag/js?id=${options.id}`,
async: true
})
this.addPlugin({
src: resolve(__dirname, './templates/plugin.js'),
fileName: 'google-gtag.js',
src: resolve(__dirname, './templates/config.js'),
fileName: 'google-gtag-config.js',
options: Object.assign({}, options),
ssr: false
})
if (!options.disableAutoPageTrack) {
this.addPlugin({
src: resolve(__dirname, './templates/plugin.js'),
fileName: 'google-gtag-plugin.js',
options: Object.assign({}, options),
ssr: false
})
}
}
}

8

lib/templates/plugin.js

@@ -1,5 +0,5 @@

import gtagjs from 'vue-gtagjs'
export default async function ({app: {router}}) {
gtagjs(router, '<%= options.id %>', <%= JSON.stringify(options.options, null, 2) %>)
export default async function ({meta,app, app: {router}}) {
router.afterEach(function (to) {
app.$gtag('config', '<%= options.id %>', {'page_path': to.fullPath})
})
}
{
"name": "@nuxtjs/google-gtag",
"version": "0.0.4",
"version": "1.0.2",
"description": "Google GTag for Nuxt.js",

@@ -32,5 +32,3 @@ "license": "MIT",

},
"dependencies": {
"vue-gtagjs": "^1.0.7"
},
"dependencies": {},
"devDependencies": {

@@ -37,0 +35,0 @@ "nuxt": "latest",

@@ -30,16 +30,9 @@ # @nuxtjs/google-gtag

// With options
['@nuxtjs/google-gtag', { /* module options */ }],
['@nuxtjs/google-gtag', { /* module options */ }],
]
// alternative also as
'google-gtag':{
// your options
}
// example config
'google-gtag':{
id: 'UA-XXXX-XX', // required
options:{
config:{
    // this are the config options for `gtag

@@ -53,3 +46,4 @@ // check out official docs: https://developers.google.com/analytics/devguides/collection/gtagjs/

},
debug: true // enable to track in dev mode
debug: true, // enable to track in dev mode
disableAutoPageTrack: false // disable if you don't want to track each page route with router.afterEach(...)
}

@@ -56,0 +50,0 @@ }

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