diff --git a/docs/_static/source-in-links.js b/docs/_static/source-in-links.js new file mode 100644 index 00000000000..a2721b2e510 --- /dev/null +++ b/docs/_static/source-in-links.js @@ -0,0 +1,22 @@ +function addUTMSourceToLink(href) { + try { + var url = new URL(href); + url.searchParams.set("utm_source", "docarray"); + return url.href + } + catch{ + return href + } +} + +function addUTMSourceToLinks() { + var anchors = document.getElementsByTagName("a"); + + for (var i = 0; i < anchors.length; i++) { + anchors[i].href = addUTMSourceToLink(anchors[i].href) + } +} + +window.onload = function () { + addUTMSourceToLinks() +} \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 8d68f8eb43f..b9ef3885adf 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -78,7 +78,8 @@ ] html_js_files = [ 'https://cdn.jsdelivr.net/npm/vue@2/dist/vue.min.js', - 'https://cdn.jsdelivr.net/npm/qabot@0.4' + 'https://cdn.jsdelivr.net/npm/qabot@0.4', + 'source-in-links.js' ] htmlhelp_basename = slug html_show_sourcelink = False