gatsby で
前提
環境情報
以下、
node.js
% node -v v8.4.0
npm
% npm -V npm@5.3.0 /usr/local/lib/node_modules/npm
gatsby
% gatsby -V 1.1.7
使用している starter に ついて
Vagr9K/gatsby-material-starter: A blog starter with Material design in mind for GatsbyJS. を
先日、
インストール、 設定
インストール
gatsby-plugin-google-tagmanager | GatsbyJSの
npm install --save gatsby-plugin-google-tagmanager ---------------------------------------------------- + gatsby-plugin-google-tagmanager@1.0.7 added 1 package in 17.097s ----------------------------------------------------
設定
plugin 記述の
追加
gatsby-config.js
にplugin 記述を 追加します。 { resolve: `gatsby-plugin-google-tagmanager`, options: { id: config.siteGTMID, }, },
gatsby-material-starter
は、設定が、 SiteConfig.js
に外だしされていますので、 GTM の ID も 外だしの 想定で config.siteGTMID
としました。 SiteConfig.js に
ID を 追加
SiteConfig.js
にGTMID を 追加します。 module.exports = { .... siteGTMID: "xxxxxxxxxx", ... }
不要な GA の 設定を 削除する
gatsby-material-starter
には、
GTM 経由で
SiteConfig.js に
トラッキング ID を 削除
以下を削除します。 siteGATrackingID: "xxxxxxxxxxxxxx", // Tracking code ID for google analytics.
plugin 記述の
削除
gatsby-config.js
のplugin 記述を 削除します。 { resolve: "gatsby-plugin-google-analytics", options: { trackingId: config.siteGATrackingID } },
gatsby-plugin-google-analytics の
アンインストール npm uninstall gatsby-plugin-google-analytics ------------------------------------------------ removed 1 package in 12.984s ------------------------------------------------
後は、gastby build
して
GTM 自体の
GTM 経由で、
Googleタグマネージャの
以上です。
コメント