@volenday/google-analytics
Advanced tools
Comparing version 0.1.1 to 0.1.2
29
index.js
@@ -1,2 +0,1 @@ | ||
const shortid = require('shortid'); | ||
const fetch = require('node-fetch'); | ||
@@ -11,19 +10,13 @@ const keyBy = require('lodash/keyBy'); | ||
let firstTag = tags.shift(); | ||
let gtags = tags.map(d => { | ||
let id = shortid.generate(); | ||
return ` | ||
ga('create', '${d}', 'auto', '${id}'); | ||
ga('${id}.send', 'pageview'); | ||
`; | ||
}); | ||
return ` | ||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | ||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); | ||
ga('create', '${firstTag}', 'auto'); | ||
ga('send', 'pageview'); | ||
${gtags.join('')} | ||
`; | ||
const firstTag = tags.shift(); | ||
const gtags = tags.map(d => `gtag('config', '${d}');`); | ||
return `<script async src="https://www.googletagmanager.com/gtag/js?id=${firstTag}"></script> | ||
<script> | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | ||
gtag('config', '${firstTag}'); | ||
${gtags.join('')} | ||
</script>`; | ||
} | ||
@@ -30,0 +23,0 @@ |
{ | ||
"name": "@volenday/google-analytics", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"private": false, | ||
@@ -10,12 +10,10 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"lodash": "~4.17.13", | ||
"node-fetch": "~2.6.0", | ||
"shortid": "~2.2.14" | ||
"lodash": "~4.17.15", | ||
"node-fetch": "~2.6.0" | ||
}, | ||
"dependencies": { | ||
"lodash": "~4.17.15", | ||
"node-fetch": "~2.6.0", | ||
"shortid": "~2.2.14" | ||
"node-fetch": "~2.6.0" | ||
}, | ||
"devDependencies": {} | ||
} |
4
2811
64
- Removedshortid@~2.2.14
- Removednanoid@3.3.8(transitive)
- Removedshortid@2.2.17(transitive)