mirror of
https://github.com/wahyd4/badger.git
synced 2026-08-09 05:15:58 +10:00
Use another way to enable google analytics
This commit is contained in:
@@ -31,22 +31,6 @@
|
||||
|
||||
</b-col>
|
||||
</b-row>
|
||||
<div v-if="isProduction">
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script
|
||||
async
|
||||
src="https://www.googletagmanager.com/gtag/js?id=UA-5243064-21"
|
||||
></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag() {
|
||||
dataLayer.push(arguments);
|
||||
}
|
||||
gtag("js", new Date());
|
||||
|
||||
gtag("config", "UA-5243064-21");
|
||||
</script>
|
||||
</div>
|
||||
</b-overlay>
|
||||
</template>
|
||||
|
||||
|
||||
+1
-2
@@ -34,8 +34,7 @@ export default {
|
||||
** Plugins to load before mounting the App
|
||||
** https://nuxtjs.org/guide/plugins
|
||||
*/
|
||||
plugins: [
|
||||
],
|
||||
plugins: [{ src: '~plugins/ga.js', mode: 'client' }],
|
||||
/*
|
||||
** Auto import components
|
||||
** See https://nuxtjs.org/api/configuration-components
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/* eslint-disable */
|
||||
|
||||
export default ({ app }) => {
|
||||
/*
|
||||
** Only run on client-side and only in production mode
|
||||
*/
|
||||
if (process.env.NODE_ENV !== "production")
|
||||
return /*
|
||||
** Include Google Analytics Script
|
||||
*/;
|
||||
(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"
|
||||
);
|
||||
/*
|
||||
** Set the current page
|
||||
*/
|
||||
ga("create", "UA-5243064-21", "auto");
|
||||
/*
|
||||
** Every time the route changes (fired on initialization too)
|
||||
*/
|
||||
app.router.afterEach((to, from) => {
|
||||
/*
|
||||
** We tell Google Analytics to add a `pageview`
|
||||
*/
|
||||
ga("set", "page", to.fullPath);
|
||||
ga("send", "pageview");
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user