From 421f9aa96320bfb085b5ec2e387b043fb6e96522 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期六, 23 七月 2022 09:37:03 +0800
Subject: [PATCH] add GTM module

---
 PAMapp/plugins/gtm.js |    4 ++++
 PAMapp/package.json   |    1 +
 PAMapp/nuxt.config.js |   34 ++++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/PAMapp/nuxt.config.js b/PAMapp/nuxt.config.js
index 64cc92d..83ed9b6 100644
--- a/PAMapp/nuxt.config.js
+++ b/PAMapp/nuxt.config.js
@@ -60,7 +60,41 @@
 
   // Modules: https://go.nuxtjs.dev/config-modules
   modules: [
+    '@nuxtjs/gtm',
   ],
+  plugins: [
+    '~/plugins/gtm'
+   ],
+  // TODO: 蝵格�甇�蝣箇�� GTM CODE
+  gtm: {
+    enabled: true, /* see below */
+    debug: false,
+
+    id: 'GTM-XXXXXXX',
+    layer: 'dataLayer',
+    variables: {},
+
+    pageTracking: true,
+    pageViewEventName: 'nuxtRoute',
+
+    autoInit: true,
+    respectDoNotTrack: true,
+
+    scriptId: 'gtm-script',
+    scriptDefer: false,
+    scriptURL: 'https://www.googletagmanager.com/gtm.js',
+    crossOrigin: false,
+
+    noscript: true,
+    noscriptId: 'gtm-noscript',
+    noscriptURL: 'https://www.googletagmanager.com/ns.html'
+  },
+
+  publicRuntimeConfig: {
+    gtm: {
+      id: process.env.GOOGLE_TAG_MANAGER_ID
+    }
+  },
 
   // Build Configuration: https://go.nuxtjs.dev/config-build
   build: {
diff --git a/PAMapp/package.json b/PAMapp/package.json
index 8f5814d..db09f1f 100644
--- a/PAMapp/package.json
+++ b/PAMapp/package.json
@@ -15,6 +15,7 @@
   },
   "dependencies": {
     "@nuxtjs/axios": "^5.13.6",
+    "@nuxtjs/gtm": "^2.4.0",
     "@nuxtjs/style-resources": "^1.2.1",
     "@types/swiper": "^5.4.3",
     "core-js": "^3.18.3",
diff --git a/PAMapp/plugins/gtm.js b/PAMapp/plugins/gtm.js
new file mode 100644
index 0000000..981a0ed
--- /dev/null
+++ b/PAMapp/plugins/gtm.js
@@ -0,0 +1,4 @@
+export default function({ $gtm, route }) {
+    // TODO: 蝵格�甇�蝣箇�� GTM CODE
+    $gtm.init('GTM-XXXXXXX')
+  }
\ No newline at end of file

--
Gitblit v1.8.0