Skip to content

Commit 78207a1

Browse files
Merge pull request #44 from clj-codes/fix/google-tag-script
fix: google-tag script
2 parents 53d9632 + 2c745d4 commit 78207a1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/codes/clj/docs/frontend/infra/analytics.cljs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
(defn google-tag
1515
[ga-tag-id gtm-script]
1616
(let [script (js/document.createElement "script")]
17-
(set! (.-src script) (str "window.dataLayer = window.dataLayer || [];
18-
function gtag(){dataLayer.push(arguments);}
19-
gtag('js', new Date());
20-
21-
gtag('config', '" ga-tag-id "');"))
17+
(set! (.-text script) (str "window.dataLayer = window.dataLayer || [];
18+
function gtag(){dataLayer.push(arguments);}
19+
gtag('js', new Date());
20+
21+
gtag('config', '" ga-tag-id "');"))
2222
(js/document.head.insertBefore script (.-nextSibling gtm-script))))
2323

2424
(defn ga-scripts

test/codes/clj/docs/frontend/test/infra/analytics_test.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
(let [ga-tag-id "G-0123456789"
99
ga-scripts (analytics/ga-scripts ga-tag-id)]
1010
(is (instance? js/HTMLScriptElement ga-scripts))
11-
(is (string/includes? (.-src ga-scripts) ga-tag-id))))
11+
(is (string/includes? (.-text ga-scripts) ga-tag-id))))
1212
(testing "blank GA_TAG_ID should not return anything"
1313
(is (nil? (analytics/ga-scripts "")))))

0 commit comments

Comments
 (0)