Skip to content

Commit

Permalink
Add click tracking of install copy command to help verify downloads (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
exactlyallan authored Aug 17, 2023
1 parent 655cbf8 commit 537fd22
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions _includes/selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
<div class="cmd">
<div class="cmd-label">Command</div>
<div class="cmd-box">
<pre class="highlight"><code><span x-ref="cmd" x-html="getCmdHtml"></span></code></pre>
<pre class="highlight"><code><span x-ref="cmd" x-html="getCmdHtml" x-on:mouseup.once="copyToGA"></span></code></pre>
</div>
</div>
</div>
Expand Down Expand Up @@ -747,13 +747,36 @@
if (this.active_additional_packages.includes("TensorFlow") && this.active_cuda_ver !== "11.2") this.active_cuda_ver = "11.2";
},
copyToClipboard() {
var range = document.createRange();
let range = document.createRange();
range.selectNode(this.$refs.cmd);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
let text = window.getSelection().toString()
document.execCommand("copy");
window.getSelection().removeAllRanges();

/** checks number of installs from copy command vs downloads **/
gtag('event', 'copyClick', {
'button': 'CopyCommand',
'install_copy_cmd': text
});
},
copyToGA(){
let range = document.createRange();
range.selectNode(this.$refs.cmd);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
let text = window.getSelection().toString()
document.execCommand("copy");
window.getSelection().removeAllRanges();

/** checks number of installs from copy vs downloads **/
/** Note mouse-up event is only sent once **/
gtag('event', 'copyMouseUp', {
'button': 'CopyCommand',
'install_copy_cmd': text
});
}
}))
})
</script>

0 comments on commit 537fd22

Please sign in to comment.