Skip to content

Commit 6f1be04

Browse files
committed
wip
1 parent 2cb9609 commit 6f1be04

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

packages/script/src/base.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,24 @@
100100
});
101101
}
102102

103+
const shouldSetCookie = () => {
104+
return (
105+
!cookieManager.get(DUB_ID_VAR) || ATTRIBUTION_MODEL !== 'first-click'
106+
);
107+
};
108+
109+
// Track clicks for dynamic pages (Eg: example.com/profile/[username])
110+
// WIP
111+
function captureClick(identifier) {
112+
if (shouldSetCookie()) {
113+
trackClick(identifier);
114+
}
115+
}
116+
103117
// Initialize tracking
104118
function init() {
105119
const params = new URLSearchParams(location.search);
106120

107-
const shouldSetCookie = () => {
108-
return (
109-
!cookieManager.get(DUB_ID_VAR) || ATTRIBUTION_MODEL !== 'first-click'
110-
);
111-
};
112-
113121
// Direct click ID in URL
114122
const clickId = params.get(DUB_ID_VAR);
115123
if (clickId && shouldSetCookie()) {
@@ -139,6 +147,10 @@
139147
n: DOMAINS_CONFIG, // was DOMAINS_CONFIG
140148
};
141149

150+
window.dubAnalytics = {
151+
trackClick: captureClick,
152+
};
153+
142154
// Initialize
143155
init();
144156
})();

packages/web/src/track-click.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { TrackClickInput } from './types';
22

33
export const trackClick = (event: TrackClickInput) => {
4-
console.log('Track click', event);
4+
console.log('trackClick', event);
55
};

0 commit comments

Comments
 (0)