Skip to content

Commit ae679fb

Browse files
committed
feat: Add GA tokenscript opened event & fix contract address format
1 parent 419b5fa commit ae679fb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

javascript/tokenscript-viewer/src/components/viewers/new/viewer-popover/viewer-popover.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,19 @@ export class ViewerPopover {
136136

137137
history.pushState(undefined, undefined, location);
138138

139+
if (window.gtag) {
140+
let data: any = {
141+
tsIdOrUrl: sourceInfo.tsId ?? sourceInfo.sourceUrl
142+
};
143+
if (params.has("chain")){
144+
data.chain = params.get("chain");
145+
data.contract = "evm:" + params.get("contract");
146+
data.scriptId = params.get("scriptId");
147+
}
148+
window.gtag('set', data);
149+
window.gtag('event', 'tokenscript_opened', data);
150+
}
151+
139152
await this.reloadOtherScripts();
140153
}
141154

javascript/tokenscript-viewer/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
gtag('config', 'G-0YTFX5PTEZ', {
3535
'viewer_type': query.has("viewType") ? query.get("viewType") : "default",
3636
'chain': query.get("chain"),
37-
'contract': query.get("contract"),
37+
'contract': "evm:" + query.get("contract"),
3838
'scriptId': query.get("scriptId")
3939
});
4040
</script>

0 commit comments

Comments
 (0)