Skip to content

Commit

Permalink
chore: add tracker script
Browse files Browse the repository at this point in the history
  • Loading branch information
tflins authored and gxglls committed Oct 25, 2023
1 parent af477d5 commit b5c434f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion website/siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const siteConfig = {
},

// Add custom scripts here that would be placed in <script> tags.
scripts: ["https://buttons.github.io/buttons.js"],
scripts: ["https://buttons.github.io/buttons.js", "/js/add-tracker.js"],

// On page navigation for the current documentation page.
onPageNav: "separate",
Expand Down
38 changes: 38 additions & 0 deletions website/static/js/add-tracker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/** Baidu Analytics */
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?cf10aaf0175b83ffccb0276a7a65b614";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();

/** Google Analytics */
(function () {
var googleScript = document.createElement("script");
googleScript.src = "https://www.googletagmanager.com/gtag/js?id=G-V0NB3342NG";
googleScript.async = true;
document.head.appendChild(googleScript);

googleScript.onload = function () {
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());

gtag("config", "G-V0NB3342NG");
};
})();

/** Google Ad */
(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-MS3N6Z8C");

0 comments on commit b5c434f

Please sign in to comment.