Socket
Socket
Sign inDemoInstall

vue-gtag

Package Overview
Dependencies
0
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.0 to 1.0.1

2

dist/vue-gtag.js

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

!function(e,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var t=n();for(var o in t)("object"==typeof exports?exports:e)[o]=t[o]}}("undefined"!=typeof self?self:this,(function(){return function(e){var n={};function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)t.d(o,r,function(n){return e[n]}.bind(null,r));return o},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){"use strict";function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,n){"undefined"!=typeof console&&(console.warn("[vue-gtag] "+e),n&&n.stack&&console.warn(n.stack))}function i(e){return"function"==typeof e}function c(e){return e&&"object"===r(e)&&!Array.isArray(e)}t.r(n);var u,f,l=function(){var e,n=_(),t=n.globalObjectName;"undefined"!=typeof window&&(e=window)[t].apply(e,arguments)},p=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var o=_(),r=o.config,a=o.includes;l.apply(void 0,["config",r.id].concat(n)),Array.isArray(a)&&a.forEach((function(e){l.apply(void 0,["config",e.id].concat(n))}))},d=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=_(),o=t.defaultGroupName,r=t.includes,a=n;r&&null==a.send_to&&(a.send_to=r.map((function(e){return e.id})).concat(o)),l("event",e,a)},s=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];d.apply(void 0,["page_view"].concat(n))},y=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];d.apply(void 0,["screen_view"].concat(n))},g=function(){var e=_().config;window["ga-disable-".concat(e.id)]=!0},v={query:l,config:p,event:d,pageview:s,screenview:y,customMap:function(e){p({custom_map:e})},time:function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];d.apply(void 0,["timing_complete"].concat(n))},exception:function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];d.apply(void 0,["exception"].concat(n))},linker:function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];d.apply(void 0,["linker"].concat(n))},purchase:function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];d.apply(void 0,["purchase"].concat(n))},set:function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];l.apply(void 0,["set"].concat(n))},optIn:function(){var e=_().config;window["ga-disable-".concat(e.id)]=!1},optOut:g},w=function(){var e=O();e.$gtag=e.prototype.$gtag=v},m=function(e,n){if(e.path!==n.path){var t,o=_(),r=o.pageTrackerTemplate,c=o.pageTrackerScreenviewEnabled,u=o.appName,f=i(r)?r(e,n):null;t=f||(c?{app_name:u,screen_name:e.name}:{page_title:e.name,page_path:e.path,page_location:window.location.href}),!c||t.app_name?!c||t.screen_name?c?y(t):s(t):a("To use the screenview, name your routes"):a("To use the screenview, add the appName to the plugin options")}},b=function(){var e=S();e&&function(e){e.onReady((function(){e.afterEach(m)}))}(e)},h=function(){if("undefined"!=typeof document&&"undefined"!=typeof window){var e=_(),n=e.enabled,t=e.globalObjectName,o=e.config,r=o.id,c=o.params,u=void 0===c?{}:c,f=e.include,l=e.pageTrackerEnabled,p=e.onReady,d=e.disableScriptLoad;if(n||g(),window.dataLayer=window.dataLayer||[],window[t]=function(){window.dataLayer.push(arguments)},window[t]("js",new Date),window[t]("config",r,u),Array.isArray(f)&&f.forEach((function(e){window[t]("config",e.id,e.params)})),l&&b(),!d){var s,y="https://www.googletagmanager.com/gtag/js?id=".concat(r);return(s=y,new Promise((function(e,n){var t=document.head||document.getElementsByTagName("head")[0],o=document.createElement("script");o.src=s,o.setAttribute("rel","preconnect"),o.setAttribute("async",!0),o.charset="utf-8",t.appendChild(o),o.onload=e,o.onerror=n}))).then((function(){var e=window[t];return i(p)&&p(e),e})).catch((function(e){return a("Ops! Something happened and gtag.js couldn't be loaded",e),e}))}}},j={enabled:!0,disableScriptLoad:!1,bootstrap:!0,globalObjectName:"gtag",pageTrackerTemplate:null,onReady:null,pageTrackerEnabled:!0,pageTrackerScreenviewEnabled:!1,defaultGroupName:"default",includes:null,config:null},_=function(){return j},A=function(e){return function e(n){for(var t=arguments.length,r=new Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];if(!r.length)return n;var i=r.shift();if(c(n)&&c(i))for(var u in i)c(i[u])?(n[u]||Object.assign(n,o({},u,{})),e(n[u],i[u])):Object.assign(n,o({},u,i[u]));return e.apply(void 0,[n].concat(r))}(j,e)},O=function(){return u},S=function(){return f};t.d(n,"bootstrap",(function(){return T})),t.d(n,"setOptions",(function(){return x}));n.default=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=arguments.length>2?arguments[2]:void 0;u=e,f=t,A(n),w(),j.bootstrap&&h()};var T=h,x=A}])}));
!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["vue-gtag"]=e():n["vue-gtag"]=e()}("undefined"!=typeof self?self:this,(function(){return function(n){var e={};function t(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return n[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}return t.m=n,t.c=e,t.d=function(n,e,o){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:o})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var r in n)t.d(o,r,function(e){return n[e]}.bind(null,r));return o},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){"use strict";function o(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function r(n){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function a(n,e){console.warn("[vue-gtag] "+n),e&&e.stack&&console.warn(e.stack)}function i(n){return"function"==typeof n}function c(n){return n&&"object"===r(n)&&!Array.isArray(n)}t.r(e);var u,f,l=function(){var n,e=A(),t=e.globalObjectName;"undefined"!=typeof window&&(n=window)[t].apply(n,arguments)},p=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];var o=A(),r=o.config,a=o.includes;l.apply(void 0,["config",r.id].concat(e)),Array.isArray(a)&&a.forEach((function(n){l.apply(void 0,["config",n.id].concat(e))}))},d=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=A(),o=t.defaultGroupName,r=t.includes,a=e;r&&null==a.send_to&&(a.send_to=r.map((function(n){return n.id})).concat(o)),l("event",n,a)},s=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];d.apply(void 0,["page_view"].concat(e))},g=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];d.apply(void 0,["screen_view"].concat(e))},y=function(){var n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=A(),t=e.config;window["ga-disable-".concat(t.id)]=n},v=function(){y(!0)},w={query:l,config:p,event:d,pageview:s,screenview:g,customMap:function(n){p({custom_map:n})},time:function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];d.apply(void 0,["timing_complete"].concat(e))},exception:function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];d.apply(void 0,["exception"].concat(e))},linker:function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];d.apply(void 0,["linker"].concat(e))},purchase:function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];d.apply(void 0,["purchase"].concat(e))},set:function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];l.apply(void 0,["set"].concat(e))},optIn:function(){y(!1)},optOut:v},b=function(){var n=S();n.$gtag=n.prototype.$gtag=w},m=function(n,e){if(n.path!==e.path){var t,o=A(),r=o.pageTrackerTemplate,c=o.pageTrackerScreenviewEnabled,u=o.appName,f=i(r)?r(n,e):null;t=f||(c?{app_name:u,screen_name:n.name}:{page_title:n.name,page_path:n.path,page_location:window.location.href}),!c||t.app_name?!c||t.screen_name?c?g(t):s(t):a("To use the screenview, name your routes"):a("To use the screenview, add the appName to the plugin options")}},h=function(){var n=T();n&&function(n){n.onReady((function(){n.afterEach(m)}))}(n)},j=function(){if("undefined"!=typeof document&&"undefined"!=typeof window){var n=A(),e=n.enabled,t=n.globalObjectName,o=n.config,r=o.id,c=o.params,u=n.includes,f=n.pageTrackerEnabled,l=n.onReady,p=n.disableScriptLoad;if(e||v(),null==window[t]&&(window.dataLayer=window.dataLayer||[],window[t]=function(){window.dataLayer.push(arguments)}),window[t]("js",new Date),c?window[t]("config",r,c):window[t]("config",r),Array.isArray(u)&&u.forEach((function(n){n.params?window[t]("config",n.id,n.params):window[t]("config",n.id)})),f&&h(),!p){var d,s="https://www.googletagmanager.com/gtag/js?id=".concat(r);return(d=s,new Promise((function(n,e){var t=document.head,o=document.createElement("script");o.src=d,o.setAttribute("rel","preconnect"),o.setAttribute("async",!0),o.charset="utf-8",t.appendChild(o),o.onload=n,o.onerror=e}))).then((function(){var n=window[t];return i(l)&&l(n),n})).catch((function(n){return a("Ops! Something happened and gtag.js couldn't be loaded",n),n}))}}},_={enabled:!0,disableScriptLoad:!1,bootstrap:!0,globalObjectName:"gtag",pageTrackerTemplate:null,onReady:null,pageTrackerEnabled:!0,pageTrackerScreenviewEnabled:!1,defaultGroupName:"default",includes:null,config:null},A=function(){return _},O=function(n){return function n(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];if(!r.length)return e;var i=r.shift();if(c(e)&&c(i)){for(var u in i)c(i[u])?(e[u]||Object.assign(e,o({},u,{})),n(e[u],i[u])):Object.assign(e,o({},u,i[u]));return n.apply(void 0,[e].concat(r))}}(_,n)},S=function(){return u},T=function(){return f};t.d(e,"bootstrap",(function(){return x})),t.d(e,"setOptions",(function(){return k}));e.default=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=arguments.length>2?arguments[2]:void 0;u=n,f=t,O(e),b(),_.bootstrap&&j()};var x=j,k=O}])}));
{
"name": "vue-gtag",
"description": "Global Site Tag (gtag.js) plugin for Vue",
"version": "0.4.0",
"version": "1.0.1",
"author": {

@@ -21,3 +21,6 @@ "name": "Matteo Gabriele",

"test": "jest",
"test:ci": "jest --coverage --bail --runInBand --verbose=false",
"coverage": "jest --coverage",
"coverage:text": "jest --coverage --coverageReporters=text",
"coverage:lcov": "jest --coverage --coverageReporters=lcov",
"prepublishOnly": "yarn lint && yarn test && webpack --mode production",

@@ -24,0 +27,0 @@ "semantic-release": "semantic-release"

@@ -1,2 +0,4 @@

<p>
<p align="center">
<img width="250" src="https://i.imgur.com/AlAf04U.png" />
<br />
<a href="https://badge.fury.io/js/vue-gtag">

@@ -6,4 +8,6 @@ <img src="https://badge.fury.io/js/vue-gtag.svg" />

<img src="https://img.shields.io/badge/size-1.80kB-brightgreen.svg" />
<img src="https://img.shields.io/badge/size-2.07kB-brightgreen.svg" />
<img src="https://travis-ci.com/MatteoGabriele/vue-gtag.svg?branch=master" />
<a href="https://codeclimate.com/github/MatteoGabriele/vue-gtag/maintainability"><img src="https://api.codeclimate.com/v1/badges/889f91b065ffc8740082/maintainability" /></a>
<a href="https://codeclimate.com/github/MatteoGabriele/vue-gtag/test_coverage"><img src="https://api.codeclimate.com/v1/badges/889f91b065ffc8740082/test_coverage" /></a>
</p>

@@ -14,7 +18,5 @@

Global Site Tag plugin for Vue (gtag.js)
Global Site Tag plugin for Vue
## Notes before you install this package
The package is maybe not ready yet for production, has no tests yet and might have limited features and lacks in documentation compared to vue-analytics.
**In case you need more flexibility and reliability, right now I still suggest you to install [vue-analytics](https://github.com/MatteoGabriele/vue-analytics) as your main tracking system.**
The global site tag (gtag.js) is a JavaScript tagging framework and API that allows you to send event data to Google Analytics, Google Ads, and Google Marketing Platform. For general gtag.js [documentation](https://developers.google.com/analytics/devguides/collection/gtagjs), read the gtag.js developer guide.

@@ -31,111 +33,18 @@ ## Requirements

## Documentation
Make sure to also give a read at the official gtag.js [documentation](https://developers.google.com/analytics/devguides/collection/gtagjs)
- [vue-gtag documentation](https://matteo-gabriele.gitbook.io/vue-gtag/)
- [gtag.js official documentation](https://developers.google.com/analytics/devguides/collection/gtagjs)
## User guide
**DOCUMENTATION: COMING SOON...**
## Issues and features requests
For now this is all I got time to write :D
Please drop an issue, if you find something that doesn't work, or a feature request at [https://github.com/MatteoGabriele/vue-gtag/issues](https://github.com/MatteoGabriele/vue-gtag/issues)
-----
Follow me on twitter [@matteo\_gabriele](https://twitter.com/matteo_gabriele) for updates
Start using it your Vue application
```js
import Vue from 'vue'
import VueGtag from 'vue-gtag'
## Sponsors
<a href="https://www.homerun.co/">
<img width="350" src="https://i.imgur.com/mjmxrfo.png" alt="Homerun.co" />
</a>
const options = {
config: {
id: 'GA_MEASUREMENT_ID' // replace GA_MEASUREMENT_ID with your ID
}
}
Vue.use(VueGtag, options)
```
Start automatic routing track by passing your VueRouter instance
```js
import Vue from 'vue'
import VueGtag from 'vue-gtag'
import VueRouter from 'vue-router'
const router = new VueRouter({
routes: [{...}]
})
const options = {
config: {
id: 'GA_MEASUREMENT_ID' // replace GA_MEASUREMENT_ID with your ID
}
}
Vue.use(VueGtag, options, router)
new Vue({
router,
render: h => h(App)
}).$mount("#app");
```
plugin default options
```js
{
enabled: true, // opt-in by default, but maybe should be opt-out by default #GDPR
globalObjectName: "gtag", // new feature in gtag.js. it's possible to change global object name
pageTrackerTemplate: () => null,
pageTrackerEnabled: false, // by default it's true if the router is passed
pageTrackerScreenviewEnabled: false, // pageviews by default
config: {
id: null, // GA_MEASUREMENT_ID
params: {
send_page_view: true // set to false is you don't want the first hit on landing
}
}
}
```
available methods within the $gtag object
it works mostly like vue-analytics structure, but with some different namings
- query,
- config,
- event,
- pageview,
- screenview,
- customMap,
- time,
- exception,
- linker,
- purchase,
- set,
- optIn,
- optOut,
- $getOptions
## Example Usage
```js
export default {
name: "Example",
methods: {
recordEvent() {
var callback = function() {
console.log("Conversion Recorded")
};
this.$gtag.event("conversion", {
send_to: "your-id-here",
event_callback: callback
});
}
}
};
```
# Issues and features requests
Please drop an issue, if you find something that doesn't work, or a feature request at [https://github.com/MatteoGabriele/vue-gtag/issues](https://github.com/MatteoGabriele/vue-gtag/issues)
Follow me on twitter [@matteo\_gabriele](https://twitter.com/matteo_gabriele)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc