Skip to content

Commit

Permalink
Merge pull request epicmaxco#631 from epicmaxco/introducing-gtm
Browse files Browse the repository at this point in the history
Replacing yandex metrics with google tag manager
  • Loading branch information
alexanderrudnik authored Aug 5, 2019
2 parents 9332dc1 + 8295867 commit f601a91
Show file tree
Hide file tree
Showing 7 changed files with 3,901 additions and 2,768 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- run:
name: Add variables for Yandex Metrics and Drift live chat
command:
echo "VUE_APP_YANDEX_METRICS_KEY=$YANDEX_METRICS_KEY" >> .env.production.local &&
echo "VUE_APP_GTM_KEY=$GTM_KEY" >> .env.production.local &&
echo "VUE_APP_DRIFT_KEY=$DRIFT_KEY" >> .env.production.local
- restore_cache: *restore_cache
- run: *install_dependencies
Expand Down
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VUE_APP_YANDEX_METRICS_KEY=
VUE_APP_GTM_KEY=
VUE_APP_DRIFT_KEY=
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"vue-bulma-expanding": "0.0.1",
"vue-chartjs": "^3.4.0",
"vue-color": "^2.7.0",
"vue-gtm": "^2.0.0",
"vue-router": "^3.0.1",
"vue-slider-component": "2.7.8",
"vue-toasted": "^1.1.25",
Expand Down
35 changes: 0 additions & 35 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,6 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Vuestic Admin</title>

<% if (process.env.NODE_ENV === 'production' && process.env.VUE_APP_YANDEX_METRICS_KEY) { %>
<!-- Yandex.Metrika counter -->
<script type="text/javascript" >
/* eslint-disable */
(function (d, w, c) {
(w[c] = w[c] || []).push(function() {
try {
w['yaCounter' + '<%= process.env.VUE_APP_YANDEX_METRICS_KEY %>'] = new Ya.Metrika2({
id: '<%= process.env.VUE_APP_YANDEX_METRICS_KEY %>',
clickmap:true,
trackLinks:true,
accurateTrackBounce:true,
webvisor:true,
trackHash:true
});
} catch(e) { }
});

var n = d.getElementsByTagName("script")[0],
s = d.createElement("script"),
f = function () { n.parentNode.insertBefore(s, n); };
s.type = "text/javascript";
s.async = true;
s.src = "https://mc.yandex.ru/metrika/tag.js";

if (w.opera == "[object Opera]") {
d.addEventListener("DOMContentLoaded", f, false);
} else { f(); }
})(document, window, "yandex_metrika_callbacks2");
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/<%= process.env.VUE_APP_YANDEX_METRICS_KEY %>" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->
<% } %>

</head>
<body>

Expand Down
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import router from './router'
import VuesticPlugin from '@/vuestic-theme/vuestic-plugin'
import './i18n'
import YmapPlugin from 'vue-yandex-maps'
import './metrics'

Vue.use(VuesticPlugin)
Vue.use(YmapPlugin)
Expand Down
10 changes: 10 additions & 0 deletions src/metrics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Vue from 'vue'
import VueGtm from 'vue-gtm'
import router from './router'

Vue.use(VueGtm, {
id: process.env.VUE_APP_GTM_KEY,
enabled: process.env.NODE_ENV === 'production',
debug: false,
vueRouter: router
})
Loading

0 comments on commit f601a91

Please sign in to comment.