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

@volenday/google-analytics

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volenday/google-analytics - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

2

config.js

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

exports.defautlGoogleAnalytics = 'UA-99304839-1';
exports.defautlGoogleAnalytics = 'GTM-KX9NGM4';
const { defautlGoogleAnalytics } = require('./config');
function generateGoogleAnalytics(tags = []) {
if (!tags.length) {
tags = [defautlGoogleAnalytics];
}
const generateGoogleAnalytics = (tag = defautlGoogleAnalytics) => {
return `<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','${tag}');</script>`;
};
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>`;
}
module.exports = (tags = '') => {
const ahaAnalytics = defautlGoogleAnalytics;
if (tags !== null && typeof tags !== 'undefined') {
if (typeof tags == 'string') {
if (tags.trim() != '') {
let tagsArr = tags.split(',');
tagsArr.unshift(ahaAnalytics);
return generateGoogleAnalytics(tagsArr);
} else {
return generateGoogleAnalytics([ahaAnalytics]);
}
} else {
let newTags = [...tags];
newTags.unshift(ahaAnalytics);
return generateGoogleAnalytics(newTags);
}
} else {
return generateGoogleAnalytics([ahaAnalytics]);
}
module.exports = (tag = '') => {
if (!tag) return generateGoogleAnalytics(defautlGoogleAnalytics);
return generateGoogleAnalytics(tag);
};
{
"name": "@volenday/google-analytics",
"version": "1.0.2",
"version": "2.0.0",
"private": false,

@@ -5,0 +5,0 @@ "license": "MIT",

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