Skip to content

Commit

Permalink
Merge pull request #1214 from casper-network/backport-gtm-plugin
Browse files Browse the repository at this point in the history
Setup Google Tag Manager plugin
  • Loading branch information
andrzej-casper authored Jul 19, 2023
2 parents 905be7e + 530f44c commit bd40246
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CROWDIN_PROJECT_ID=468254
# Google analytics credentials
GOOGLE_TAG_ANONYMIZE_IP=REPLACE_WITH_YOUR_GOOGLE_ANALYTICS_TRACKING_ID
GOOGLE_TAG_TRACKING_ID=REPLACE_WITH_YOUR_GOOGLE_TAG_TRACKING_ID
GOOGLE_TAG_MANAGER_ID=REPLACE_WITH_YOUR_GOOGLE_TAG_MANAGER_ID

# Site navbar
DIRECTUS_URL=REPLACE_WITH_YOUR_DIRECTUS_URL
Expand Down
1 change: 1 addition & 0 deletions .github/templates/.env.production.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CROWDIN_PERSONAL_ACCESS_TOKEN={{ env['CROWDIN_PERSONAL_ACCESS_TOKEN'] }}
# Google analytics credentials
GOOGLE_TAG_ANONYMIZE_IP={{ env['GOOGLE_TAG_ANONYMIZE_IP'] }}
GOOGLE_TAG_TRACKING_ID={{ env['GOOGLE_TAG_TRACKING_ID'] }}
GOOGLE_TAG_MANAGER_ID={{ env['GOOGLE_TAG_MANAGER_ID'] }}

# Site navbar
DIRECTUS_URL={{ env['DIRECTUS_URL'] }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
CROWDIN_PERSONAL_ACCESS_TOKEN: ""
GOOGLE_TAG_ANONYMIZE_IP: ${{ vars.GOOGLE_TAG_ANONYMIZE_IP }}
GOOGLE_TAG_TRACKING_ID: ${{ vars.GOOGLE_TAG_TRACKING_ID }}
GOOGLE_TAG_MANAGER_ID: ${{ vars.GOOGLE_TAG_MANAGER_ID }}
DIRECTUS_URL: ${{ secrets.DIRECTUS_URL }}
DIRECTUS_GRAPHQL_URL: ${{ secrets.DIRECTUS_GRAPHQL_URL }}
DIRECTUS_TOKEN: ${{ secrets.DIRECTUS_TOKEN }}
Expand Down
5 changes: 5 additions & 0 deletions config/gtm.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const gtmId = process.env.GOOGLE_TAG_MANAGER_ID;

module.exports = {
containerId: gtmId,
};
2 changes: 2 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const colorConfig = require("./color.config");
const dataConfig = require("./data.config");
const footerConfig = require("./footer.config");
const gtagConfig = require("./gtag.config");
const gtmConfig = require("./gtm.config");
const i18nConfig = require("./i18n.config");
const metadatasConfig = require("./metadatas.config");
const navbarConfig = require("./navbar.config");
Expand All @@ -22,6 +23,7 @@ module.exports = {
dataConfig,
footerConfig,
gtagConfig,
gtmConfig,
i18nConfig,
metadatasConfig,
navbarConfig,
Expand Down
2 changes: 2 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {
dataConfig,
footerConfig,
gtagConfig,
gtmConfig,
i18nConfig,
metadatasConfig,
navbarConfig,
Expand Down Expand Up @@ -70,6 +71,7 @@ module.exports = {
// onlyIncludeVersions: process.env.PREVIEW_DEPLOY === "true" ? ["current", ...versions.slice(0, 2)] : undefined,
},
...(gtagConfig["trackingID"] && { gtag: gtagConfig }),
...(gtmConfig["containerId"] && { googleTagManager: gtmConfig }),
// IMPORTANT: disable blog feature
blog: false,
/* Blog config options */
Expand Down

0 comments on commit bd40246

Please sign in to comment.