Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@
<html lang="ko">
<head>
<meta charset="utf-8">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BEBVKYH8HL"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-C5V0X2SGD3"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-BEBVKYH8HL');
gtag('config', 'G-C5V0X2SGD3', { page_location: location.href });
/* GA has the campaign from page_location; keep shared URLs free of utm_* */
(function () {
try {
var u = new URL(location.href), drop = [];
u.searchParams.forEach(function (v, k) { if (k.indexOf("utm_") === 0) drop.push(k); });
if (drop.length) { drop.forEach(function (k) { u.searchParams.delete(k); }); history.replaceState(history.state, "", u.pathname + u.search + u.hash); }
} catch (e) {}
})();
</script>
<script src="/assets/js/track.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>페이지를 찾을 수 없습니다 | Causal Inference Hub</title>
<link rel="icon" href="/assets/img/team-mark.png">
Expand Down
13 changes: 11 additions & 2 deletions article.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@
<html lang="ko">
<head>
<meta charset="utf-8">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BEBVKYH8HL"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-C5V0X2SGD3"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-BEBVKYH8HL');
gtag('config', 'G-C5V0X2SGD3', { page_location: location.href });
/* GA has the campaign from page_location; keep shared URLs free of utm_* */
(function () {
try {
var u = new URL(location.href), drop = [];
u.searchParams.forEach(function (v, k) { if (k.indexOf("utm_") === 0) drop.push(k); });
if (drop.length) { drop.forEach(function (k) { u.searchParams.delete(k); }); history.replaceState(history.state, "", u.pathname + u.search + u.hash); }
} catch (e) {}
})();
</script>
<script src="assets/js/track.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>읽을거리 | Causal Inference Hub</title>
<meta name="description" content="가짜연구소 인과추론팀이 쓴 글과 독자를 위한 자료입니다.">
Expand Down
1 change: 1 addition & 0 deletions assets/js/hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@
function openStation(id) {
const r = state.repos.get(id);
if (!r) return;
if (window.hubTrack) window.hubTrack("station_open", { repo: id, level: r.level || "", from_link: stationFromHash() === id ? "yes" : "no" });
if (r.kind !== "paid") {
state.recent = [{ id, t: Date.now() }, ...state.recent.filter((x) => x.id !== id)].slice(0, 6);
saveRecent(); renderWeek();
Expand Down
51 changes: 51 additions & 0 deletions assets/js/track.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* Analytics helpers shared by every hub page.
- hubTrack(name, params): send a GA4 event when the tag is present.
- Links to the team's other sites on this domain (the web book, causal-studio, ...) open in the same tab,
carry utm_* so the other site's GA property can see the visit came from the hub, and send a click event. */
(function () {
"use strict";
window.hubTrack = function (name, params) {
try { if (typeof window.gtag === "function") window.gtag("event", name, params || {}); } catch (e) {}
};

const HUB_PATHS = /^\/(?:$|index\.html$|article\.html$|404\.html$|assets\/|data\/|articles\/)/;
const WEBBOOK = "Causal-Inference-with-Python";

function teamSite(a) {
let u;
try { u = new URL(a.href, location.href); } catch (e) { return null; }
if (u.origin !== location.origin || HUB_PATHS.test(u.pathname)) return null;
const site = u.pathname.split("/")[1];
return site ? { url: u, site } : null;
}

function placement(a) {
const spots = [
["#featured", "featured"], [".partner", "partner"], ["#station-dialog", "station"],
["#shelf, #week, .spot", "curriculum"], [".reader, .prose", "article"], [".site-footer", "footer"], [".banner", "banner"]
];
for (const [sel, name] of spots) if (a.closest(sel)) return name;
return "other";
}

function decorate(e) {
const a = e.target.closest && e.target.closest("a[href]");
if (!a) return;
const t = teamSite(a);
if (!t) return;
const where = placement(a);
const u = t.url;
if (!u.searchParams.has("utm_source")) {
u.searchParams.set("utm_source", "hub");
u.searchParams.set("utm_medium", "referral");
u.searchParams.set("utm_campaign", "crosslink");
u.searchParams.set("utm_content", where);
a.href = u.toString();
}
/* team sites are one family: open them in place, unless the reader asked for a new tab */
if (e.type === "click" && e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey) a.removeAttribute("target");
window.hubTrack(t.site === WEBBOOK ? "webbook_click" : "team_site_click", { site: t.site, placement: where, link_url: u.origin + u.pathname });
}
document.addEventListener("click", decorate, true);
document.addEventListener("auxclick", decorate, true);
})();
13 changes: 11 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@
<html lang="ko">
<head>
<meta charset="utf-8">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BEBVKYH8HL"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-C5V0X2SGD3"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-BEBVKYH8HL');
gtag('config', 'G-C5V0X2SGD3', { page_location: location.href });
/* GA has the campaign from page_location; keep shared URLs free of utm_* */
(function () {
try {
var u = new URL(location.href), drop = [];
u.searchParams.forEach(function (v, k) { if (k.indexOf("utm_") === 0) drop.push(k); });
if (drop.length) { drop.forEach(function (k) { u.searchParams.delete(k); }); history.replaceState(history.state, "", u.pathname + u.search + u.hash); }
} catch (e) {}
})();
</script>
<script src="assets/js/track.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>Causal Inference Hub | 가짜연구소 인과추론팀</title>
<meta name="description" content="인과추론에서 AI 시대의 데이터 리터러시까지. 가짜연구소 인과추론팀이 2022년부터 함께 만든 오픈소스와 커리큘럼을 한곳에 모은 허브입니다.">
Expand Down