Skip to content

Commit

Permalink
googleAnalytics重新更改
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhongpeng committed Jun 18, 2019
1 parent d88e896 commit f7ca980
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
5 changes: 4 additions & 1 deletion changeVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ let list = config.match(/"version": ?"([0-9\.]+)"/);
if (!list || list.length < 1) return;
let v_list = list[1].split('.');
var a = 0
for (let i = 0; i < v_list.length; i++) {
for (let i = 1; i < v_list.length; i++) {
if (v_list[i] < 10) {
a = i
} else {
v_list[i] = 0
break
}
}
try {
Expand Down
36 changes: 19 additions & 17 deletions enhanceApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,33 @@ export default ({
a = s.createElement(o)
m = s.getElementsByTagName(o)[0]
a.async = 1
a.src = g+"?id="+GA_ID
a.src = g + "?id=" + GA_ID
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga')
// window.dataLayer = window.dataLayer || [];
// function gtag() {
// if (dataLayer.indexOf(arguments) === -1) {
// dataLayer.push(arguments);
// }
// }
// gtag('js', new Date());
// gtag('config', GA_ID);

// ga('create', GA_ID, 'auto')
// ga('set', 'anonymizeIp', true)
// ga('send', 'pageview')

window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', GA_ID);
ga('create', GA_ID, 'auto');
ga('send', 'pageview');

router.afterEach(function (to) {
// ga('set', 'page', to.fullPath)
// ga('send', 'pageview')
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config',GA_ID);
ga('set', 'page', to.path);
ga('send', 'pageview');
})
}
};
// < !--Global site tag(gtag.js) - Google Analytics-- >
// <!--Global site tag(gtag.js) - Google Analytics-- >
// <script async src="https://www.googletagmanager.com/gtag/js?id=UA-139922393-1"></script>
// <script>

// window.dataLayer = window.dataLayer || [];
// function gtag(){dataLayer.push(arguments); }
// gtag('js', new Date());

// gtag('config', 'UA-139922393-1');
// </script>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vuepress-theme-reform",
"version": "1.3.10",
"version": "1.4.0",
"description": "a theme for vuepress",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit f7ca980

Please sign in to comment.