Skip to content

Commit

Permalink
fix: Add google analytics tag script to fix CI/CD error
Browse files Browse the repository at this point in the history
  • Loading branch information
JeongHeanKim committed Sep 21, 2023
1 parent 4add769 commit f7585ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 1 addition & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,9 @@ build_for_release:
before_script:
- npm ci --cache .npm --prefer-offline
script:
- bash add_google_analytics_tag.sh
- npm run build
- cp -rp dist/* public
- >
TARGET='\<script\>(function (w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != "dataLayer" ? "&l=" + l : ""; j.async = true; j.src = "https:\/\/www.googletagmanager.com\/gtm.js?id=" + i + dl; f.parentNode.insertBefore(j, f); })(window, document, "script", "dataLayer", "GTM-W6T5HDN");\<\/script\> \<noscript\>\<iframe src="https:\/\/www.googletagmanager.com\/ns.html?id=GTM-W6T5HDN" height="0" width="0" style="display:none;visibility:hidden"\>\<\/iframe\>\<\/noscript\>\<\/head\>'
SOURCE='\<\/head\>'
sed -i "" "s/$SOURCE/$TARGET/g" public/index.html
artifacts:
paths:
- public
Expand Down
4 changes: 4 additions & 0 deletions add_google_analytics_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TARGET='\<script\>(function (w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != "dataLayer" ? "&l=" + l : ""; j.async = true; j.src = "https:\/\/www.googletagmanager.com\/gtm.js?id=" + i + dl; f.parentNode.insertBefore(j, f); })(window, document, "script", "dataLayer", "GTM-W6T5HDN");\<\/script\> \<noscript\>\<iframe src="https:\/\/www.googletagmanager.com\/ns.html?id=GTM-W6T5HDN" height="0" width="0" style="display:none;visibility:hidden"\>\<\/iframe\>\<\/noscript\>\<\/head\>'
SOURCE='\<\/head\>'

sed -i "" "s/$SOURCE/$TARGET/g" public/index.html

0 comments on commit f7585ed

Please sign in to comment.